---
title: "Fix PMD WQL Single Quotes and Double URL-Encoded Unicode"
description: "Build multi-value WQL IN clauses from comma-separated attributes and decode instanceListQuery with string:urlDecode() so Chinese and non-ASCII searches work."
url: https://kiweely.com/guides/wql-pmd-single-quote-escaping-double-urlencoded-unicode
---

# 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.

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

## Problem 1: Multi-value `IN (...)` clauses fail with `Specify a valid value for the field`

When an Extend app stores multiple Workday IDs (`WID`s) or reference IDs in a single comma-separated App Attribute (`attrstore`) or page variable—such as `2ad818e8149b4bf88aa6deb6ad4162ca,b4f7687c800442b6b2bddc9f7e70f6ba`—iterating directly over the attribute in a Presentation Metadata (`PMD`) script treats the entire comma-separated string as a single element or produces an empty list.

If you run:

javascript

```
var trackTypeIds = [];
var q = String.fromCharCode(39);
for (var id : attrstore.academicTrackTypes) {
  trackTypeIds.add(q + id + q);
}
var trackTypeIdList = trackTypeIds.join(',');
```

the resulting `WQL` query wraps the entire comma-separated string inside a single pair of quotes instead of quoting each ID separately:

sql

```
-- Broken output: treated as one literal 65-character ID
SELECT academicTrackTypeName, referenceID1, workdayID
FROM academicTrackTypes
WHERE workdayID IN ('2ad818e8149b4bf88aa6deb6ad4162ca,b4f7687c800442b6b2bddc9f7e70f6ba')
```

Workday rejects this `WQL` request with HTTP 400:

text

```
{error=invalid request: WQL error., errors=[{error=Specify a valid value for the field. The field value is empty or invalid.}]}
```

Conversely, if you use an arrow function with braces inside `.map(id => { ... })` without an explicit `return` statement, every element evaluates to `null` and produces `WHERE workdayID IN ()`, which fails with the same `Specify a valid value for the field` error.

### Fix: Split the string on commas, trim each ID, and wrap each item in single quotes

Before building the `IN (...)` list, split the raw string with `.split(',')`, trim whitespace from each token, wrap each individual ID in single quotes `'...'`, and join with a comma:

javascript

```
<%
  var raw = attrstore.academicTrackTypes;
  var academicTrackTypes = raw ? raw.split(',') : [];
  var trackTypeIds = [];
  for (var id : academicTrackTypes) {
    if (!empty(id.trim())) {
      trackTypeIds.add("'" + id.trim() + "'");
    }
  }
  var trackTypeIdList = trackTypeIds.join(',');
  var queryString = "SELECT academicTrackTypeName, referenceID1, workdayID FROM academicTrackTypes WHERE workdayID IN (" + trackTypeIdList + ")";
  return "/data?query=" + string:urlEncode(queryString);
%>
```

This produces the valid `WQL` syntax required by `/wql/v1/data`:

sql

```
SELECT academicTrackTypeName, referenceID1, workdayID
FROM academicTrackTypes
WHERE workdayID IN ('2ad818e8149b4bf88aa6deb6ad4162ca','b4f7687c800442b6b2bddc9f7e70f6ba')
```

If a user-supplied string value inside a `WQL` literal can itself contain a single quote (such as an organization or last name like `O'Connor`), escape embedded single quotes before wrapping the value so the `WHERE` parser does not terminate the literal early.

## Problem 2: Chinese and non-ASCII characters return 0 results in `instanceList` WQL search endpoints

When you configure an `instanceList` widget with a server-side `searchEndPoint` backed by `WQL`, the user’s search term is passed into your inbound endpoint via `instanceListQuery`. If a user types a Chinese, Japanese, Korean, or accented name—for example, `陳安迪`—running the raw `WQL` query in **View WQL Query Result** returns the matching worker, but typing `陳安迪` into the `instanceList` search box on the Extend page returns zero matches.

Inspecting the generated `WQL` query in the PMD logs reveals why:

sql

```
SELECT workdayID AS id,
       fullName AS descriptor,
       company,
       supervisoryOrganization,
       cf_CFEXTTXTWorkerDisplayName
FROM workersForHCMReporting (dataSourceFilter = allActiveWorkers)
WHERE (
  employeeID CONTAINS '%E9%99%B3%E5%AE%89%E8%BF%AA'
  OR fullName CONTAINS '%E9%99%B3%E5%AE%89%E8%BF%AA'
  OR cf_CFEXTTXTWorkerDisplayName CONTAINS '%E9%99%B3%E5%AE%89%E8%BF%AA'
)
```

Workday’s presentation runtime passes `instanceListQuery` into the search endpoint **already URL-encoded** (`%E9%99%B3%E5%AE%89%E8%BF%AA` for the UTF-8 bytes of `陳安迪`). When your endpoint script concatenates `instanceListQuery` into the `WHERE` clause and then calls `string:urlEncode(query)` on the full `WQL` statement, every `%` sign in `%E9%99%B3%E5%AE%89%E8%BF%AA` is encoded a second time into `%25E9%2599%25B3%25E5%25AE%2589%25E8%25BF%25AA`. Workday then decodes the query string once on arrival at `/wql/v1/data` and searches for the literal ASCII characters `%E9%99%B3%E5%AE%89%E8%BF%AA` instead of `陳安迪`.

### Fix: Call `string:urlDecode(instanceListQuery ?? '')` before constructing the WQL query

Always decode `instanceListQuery` back into a UTF-8 string using `string:urlDecode(...)` (or the instance method `.urlDecode()`) before concatenating it into your `WQL` condition, and then call `string:urlEncode(...)` exactly once on the complete query string at the `return` statement:

javascript

```
{
  "name": "workerSearchEndpoint",
  "baseUrlType": "WORKDAY-WQL",
  "authType": "sso",
  "deferred": true,
  "url": "<%
    var searchText = string:urlDecode(instanceListQuery ?? '').trim();
    var selectStatement = 'SELECT workdayID AS id, fullName AS descriptor, company, supervisoryOrganization, cf_CFEXTTXTWorkerDisplayName ';
    var dataSource = 'FROM workersForHCMReporting (dataSourceFilter = allActiveWorkers)';
    var searchCondition = '(employeeID CONTAINS \'' + searchText + '\' OR fullName CONTAINS \'' + searchText + '\' OR cf_CFEXTTXTWorkerDisplayName CONTAINS \'' + searchText + '\')';
    var query = selectStatement + dataSource + ' WHERE ' + searchCondition;
    return '/data?query=' + string:urlEncode(query);
  %>"
}
```

Decoding `instanceListQuery` first is safe for ASCII input as well: ASCII characters pass through `string:urlDecode` unchanged, encoded spaces (`+` or `%20`) become normal spaces inside the `CONTAINS '...'` literal, and multi-byte UTF-8 characters are restored to their actual Unicode characters before the final `string:urlEncode(query)` encodes the entire query parameter once.

## How to verify the fix in your tenant

1.  Add `console.info(query);` right before `return '/data?query=' + string:urlEncode(query);` in your PMD endpoint script.
2.  Preview the page, open the `instanceList` dropdown, and search for a worker using non-ASCII characters (such as `陳安迪` or an accented name) and a space-separated full name.
3.  Check the developer console log to confirm the unencoded `query` string contains the readable Unicode script characters and properly quoted `'id1','id2'` values in `IN (...)`, and verify the dropdown populates with the matching worker records.

## Sources checked

-   [urlDecode ( )](https://developer.workday.com/documentation/jpj1527659318677)
-   [urlEncode ( )](https://developer.workday.com/documentation/fhz1526275637049)
-   [instanceList](https://developer.workday.com/documentation/hcb1512514976081)
-   [Concept: instanceList](https://developer.workday.com/documentation/GUID-17f49183-14bb-4cd3-95a1-1e3dd8ded432-enHYPHENus)
-   [Reference: WQL REST API](https://developer.workday.com/documentation/GUID-5c940864-7651-4e28-a9d2-79b45292e66a-enHYPHENus)

## Related guides

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

-   [### Why PATCH from an SSO PMD Page Fails with unrecognized field While the Same Payload Succeeds in Postman When a PATCH request to an Extend Model Business Object fails with 400 unrecognized field from an SSO PMD page even though the same fields succeed in Postman, widget valueOutBinding declarations are merging extra keys into self.data. Log json:asJSON(self.data) and return a clean payload in onSend.](https://kiweely.com/guides/workday-extend-pmd-patch-unrecognised-field-sso-vs-postman)
-   [### 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().](https://kiweely.com/guides/wql-workerdocuments-filelength-returns-52)
-   [### 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)

-   [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)
-   [WQL 500-Instance Related Business Object Limit and Large IN (...) Filter Limits](https://kiweely.com/guides/wql-500-rbo-instances-per-row-large-in-filter-limits)

### From the blog on WQL

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

-   [Answering Executive Span-of-Control and Headcount Questions Live from Workday](https://kiweely.com/blog/executive-org-span-of-control-attrition-questions-live-workday)
-   [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)

## 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.
