---
title: "Fix workerDocuments fileLength Returning 52 in WQL — Kiweely"
description: "Why the fileLength field on workerDocuments returns 52 or 0 in WQL for business process attachments, and how to read true byte size with Data.contentLength()."
url: https://kiweely.com/guides/wql-workerdocuments-filelength-returns-52
---

# Why fileLength on workerDocuments Returns 52 in WQL for Business Process Attachments

Querying fileLength on the workerDocuments related business object in WQL returns a constant 52 (or 0) whenever the document was attached through a business process event. Retrieve the actual byte length in Workday Orchestrate using Data.contentLength().

-   **Checked** against Workday on November 6
-   Applies to **Workday Query Language**
-   3 min read
-   Published November 6
-   By Kiweely

## Why `fileLength` on `workerDocuments` returns `52` in WQL

When you query worker attachments through Workday Query Language (`WQL`) using the `workerDocuments` Related Business Object (`RBO`) on `workersForHCMReporting`, the `fileLength` field frequently returns `"fileLength": 52` (or occasionally `0`) for every returned file regardless of whether the actual PDF or Word document is 7 KB or 400 KB:

sql

```
SELECT workerDocuments{workdayID, fileName, fileLength, workerDocumentCategory}
FROM workersForHCMReporting (dataSourceFilter = allActiveWorkers)
WHERE ON workerDocuments workerDocumentCategory = 'c0561bb4424d01055d8c3419cc0000'
WHERE worker = '3aa5550b7fe348b98d7b5741afc65534'
```

The `GET /wql/v1/data` response looks like this even for multi-page PDF files:

json

```
{
  "fileLength": 52,
  "fileName": "signed-employment-agreement.pdf",
  "workdayID": "c1a822a2c1a41012126f2bb624820000",
  "workerDocumentCategory": {
    "descriptor": "Absence",
    "id": "c0561bb4424d01055d8c3419cc0000"
  }
}
```

This happens because the delivered `File Length` report field (`wid: 524f73df9603100002803c6a59ba000f`) on `Worker Document` only reports real byte lengths for documents uploaded directly to the worker profile (**Maintain Worker Documents**). When a document is attached as part of a **Business Process Event** (such as **Hire**, **Change Job**, **Request Leave of Absence**, or **Complete Form I-9**) and surfaced under `workerDocuments`, Workday does not populate the byte length attribute read by that field. Whenever no stored file length is available on the business process attachment wrapper, Workday outputs the sentinel value `52` (or `0`).

You can observe both behaviors side by side on standard sample workers who have a mix of direct uploads and business-process-attached documents: documents uploaded directly to the worker’s **Documents** tab show their true byte count (for example, `48210`), while documents attached during a business process step show `52`.

## Why you cannot use WQL `fileLength` to pre-batch ZIP archives

A common reason developers select `fileLength` in `WQL` is to calculate cumulative batch sizes before downloading files—for example, grouping worker PDFs into chunks under 10 MB or 25 MB before aggregating them into a `Zip Archive` step in Workday Orchestrate and sending them to an external API or **Put Drive Document Content**.

Because `fileLength` returns `52` for business process attachments, any pre-fetch batching logic based on `SUM(fileLength)` or summing `row.fileLength` in Presentation Metadata (`PMD`) or Orchestrate will severely underestimate the batch size, allowing hundreds of megabytes of PDFs into a single batch and triggering orchestration memory or message size failures.

## Measuring true byte size with `Data.contentLength()` in Orchestrate

Because the true byte length of a business-process-attached worker document is not exposed in `WQL` metadata, you must measure the size on the retrieved document payload inside your orchestration using the `contentLength()` member function on the `Data` object.

### 1\. Query the document list in WQL without relying on `fileLength`

Use `WQL` to retrieve the `workdayID`, `fileName`, and `workerDocumentCategory` of each target document on the worker:

sql

```
SELECT worker,
       workerDocuments{workdayID, fileName, workerDocumentCategory}
FROM workersForHCMReporting (dataSourceFilter = allActiveWorkers)
WHERE worker = '3aa5550b7fe348b98d7b5741afc65534'
  AND workerDocuments IS NOT EMPTY
```

### 2\. Fetch the document content and inspect `.contentLength()`

Inside your orchestration loop over `workerDocuments`, retrieve the document content (via the Workday REST or SOAP `Get_Worker_Documents` / attachment retrieval step). When you have the binary stream or decoded `Data` entity in Orchestrate, call `.contentLength()` to obtain the exact size in bytes:

javascript

```
// Measure the exact byte length of the retrieved binary payload
data.RetrieveWorkerDocument.response.contentLength()

// Or when converting a Base64 string from a SOAP response into bytes first:
data.GetWorkerDocumentSoap.response
  .asXML()
  .stringAtXPath("//wd:File")
  .base64DecodeToBytes()
  .contentLength()
```

### 3\. Enforce cumulative batch size limits dynamically

If you are aggregating documents into a ZIP archive or multipart upload that must stay under an external payload threshold (for example, 15 MB = `15728640` bytes):

1.  Initialize an orchestration variable `runningBatchBytes = 0` via a **Create Values** step before the loop.
2.  On each iteration, after retrieving the document and converting it to binary, evaluate `docBytes = data.DecodedDocument.binaryData.contentLength()`.
3.  Add a **Branch on Conditions** step checking whether `data.BatchState.runningBatchBytes.plus(data.CurrentDoc.docBytes)` exceeds your byte ceiling (`15728640`).
4.  When the ceiling is reached, flush or upload the current archive, reset `runningBatchBytes` to the current document’s `docBytes`, and continue processing the remaining documents.

## How to verify the fix in your tenant

1.  In your tenant, open a worker profile that has both a directly uploaded worker document and a document attached during a **Hire** or **Absence** business process event.
2.  Run **View WQL Query Result** with `SELECT workerDocuments{workdayID, fileName, fileLength} FROM workersForHCMReporting WHERE worker = '<workerWID>'` and confirm which rows return `52`.
3.  Run your orchestration in **Orchestration Builder** and log the output of `.contentLength()` in an **Integration Message** or **Create Values** step. Verify that `.contentLength()` reports the exact byte count matching the downloaded file on disk for every `52`\-byte row.

## Sources checked

-   [Concept: Related Business Objects in WQL](https://developer.workday.com/documentation/GUID-5295e235-6d69-4b80-ad51-510afbdfb853-enHYPHENus)
-   [Reference: WQL REST API](https://developer.workday.com/documentation/GUID-5c940864-7651-4e28-a9d2-79b45292e66a-enHYPHENus)
-   [Integration App Data](https://developer.workday.com/documentation/GUID-db0cb823-d25f-41af-85db-0abbb5b06ca3-enHYPHENus)
-   [Concept: Workday Query Language (WQL)](https://doc.workday.com/admin-guide/en-us/reporting-and-analytics/custom-reports-and-analytics/workday-query-language-wql-/aht1611188422513.html)

## Related guides

[All guides](https://kiweely.com/guides)

-   [### Why Attachment Model Components and contentType Are Missing from the GraphQL Schema After Migrating to IMPL After promoting a Workday Extend app with an Attachment Business Object to an Implementation or Sandbox tenant, GraphQL queries can fail with Unknown type \_DataSources or missing contentType fields. Refresh the model cache, verify ISU domain security, and check tenant Graph schema availability.](https://kiweely.com/guides/workday-graphql-attachment-schema-contenttype-missing-impl)
-   [### Escaping Single Quotes for Multi-Value IN Clauses and Fixing Double URL-Encoded Unicode in PMD WQL Dynamic WQL queries in Workday Extend PMD fail when comma-separated attribute strings are wrapped in a single pair of quotes or when instanceListQuery is double URL-encoded. Split and quote each ID individually, and call string:urlDecode(instanceListQuery) before building the WQL string.](https://kiweely.com/guides/wql-pmd-single-quote-escaping-double-urlencoded-unicode)
-   [### Filtering WQL Queries by Organization Hierarchy and workersByRole Without Throwing Security Errors To return workers in an HR Partner’s assigned organizations and subordinate hierarchies, use workersForHCMReporting with dataSourceFilter = workersByRole. Guard the endpoint with an exclude check so users without the constrained role do not trigger a hard WQL error.](https://kiweely.com/guides/wql-organization-hierarchy-filter-workersbyrole)
-   [### Why WQL Queries on findCandidates and allWorkers Return Empty Right After a Business Process Step WQL queries triggered during a Workday business process often return zero rows for two distinct reasons: the transaction has not committed yet, or the query reads an eventually consistent indexed data source like findCandidates. Trigger on Completed status or pass launch parameters directly.](https://kiweely.com/guides/wql-indexing-delay-findcandidates-bp-status-change)

### More guides on WQL

[All 31 guides](https://kiweely.com/guides#wql)

-   [Paging with POST /wql/v1/data in a PMD Grid When Queries Exceed URL Limits](https://kiweely.com/guides/wql-post-data-endpoint-grid-pagination-url-limit)
-   [Fixing WQL Error 804 on GROUP BY and Related Business Object Aggregation Limits](https://kiweely.com/guides/wql-group-by-error-804-rbo-aggregation-limits)
-   [Fixing WQL Error “Empty Required Parm Moment\_Parm” with SUM()](https://kiweely.com/guides/wql-empty-required-parm-moment-parm-sum)
-   [Fixing WQL “Cannot construct instance source on grouped results” with COUNT(DISTINCT)](https://kiweely.com/guides/wql-count-distinct-with-where-on-rbo-filter)
-   [Why WHERE fieldA = fieldB Throws “Invalid Where Clause” in WQL](https://kiweely.com/guides/wql-compare-two-fields-where-clause-invalid)
-   [Filtering Empty Related Business Objects in WQL and Guarding Omitted RBO Keys in PMD](https://kiweely.com/guides/wql-check-rbo-empty-missing-json-keys-pmd)
-   [Fixing WQL “Specify a valid report field” and HTTP 500 Errors When an ISU Queries Calculated Fields](https://kiweely.com/guides/wql-calculated-field-isu-specify-valid-report-field-500)
-   [Why WQL AVG() Rounds to Whole Numbers and How to Handle Conditional Logic Without CASE](https://kiweely.com/guides/wql-avg-integer-rounding-conditional-logic-without-case)

### From the blog on WQL

[All posts](https://kiweely.com/blog)

-   [Build vs. Buy a Workday MCP Server: OAuth 2.1, SOAP, WQL, and Twice-Yearly Releases](https://kiweely.com/blog/build-vs-buy-workday-mcp-server-engineering-cost)
-   [What happens after ChatGPT writes your WQL query](https://kiweely.com/blog/after-chatgpt-writes-your-wql)
-   [Answering Executive Span-of-Control and Headcount Questions Live from Workday](https://kiweely.com/blog/executive-org-span-of-control-attrition-questions-live-workday)

## Let Workday check the work.

Kiweely writes WQL and builds orchestrations in your own tenant, and Workday, not Kiweely, says whether they passed.

[Start for free](https://kiweely.com/download) [See how it works](https://kiweely.com/vine/how-it-works)

## Get the next guide in your inbox.

One email a month with new guides and one Extend tip. Nothing else.
