---
title: "UUIDs & stringAtJsonPath().toNumber() in Orchestrate"
description: "Generate unique IDs in Workday Orchestrate using random.randomUUID() or Sequence Generators, and fix stringAtJsonPath().toNumber() expression errors."
url: https://kiweely.com/guides/workday-orchestrate-randomuuid-stringatjsonpath-tonumber
---

# Generating UUIDs with random.randomUUID() and Fixing stringAtJsonPath().toNumber() in Orchestrate

Workday Orchestrate uses random.randomUUID() instead of PMD’s UUID() function to generate unique batch IDs, and requires chaining .toNumber() on the outer stringAtJsonPath() function rather than inside the JSONPath literal.

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

## Generating Unique IDs in Orchestrate with `random.randomUUID()`

In Workday Extend presentation (`.pmd`) scripts, developers call `UUID()` to generate a unique identifier. In **Workday Orchestrate**, `UUID()` does not exist; the equivalent expression function is `random.randomUUID()` under the `random` global function qualifier.

`random.randomUUID()` takes no arguments and returns a `String` containing a standard 36-character RFC 4122 type 4 pseudorandom UUID (for example, `"550e8400-e29b-41d4-a716-446655440000"`).

### Populating Unique SOAP Batch Entry IDs (`Import_Time_Off_Request_Event_Batch`)

Many high-volume Workday SOAP import operations—such as `Import_Time_Off_Request_Event_Batch_Request` in the Absence Management service—require a tenant-unique reference ID (`Time_Off_Entry_ID`) on every imported entry row. If a batch contains 150–200 time-off entries, calling a separate web service on every loop iteration adds unnecessary latency.

Instead, invoke `random.randomUUID()` directly inside a **Create Values** step within your **Loop** or inline inside a **Create Text Template** (`{{#each}}`) block so each entry receives a fresh UUID at template evaluation time:

xml

```
<bsvc:Import_Time_Off_Request_Event_Batch_Request xmlns:bsvc="urn:com.workday/bsvc" bsvc:version="v46.2">
  {{#each data.FetchTimeOffRows.response.iterator("$.entries[*]")}}
  <bsvc:Enter_Time_Off_Data>
    <bsvc:Worker_Reference>
      <bsvc:ID bsvc:type="Employee_ID">{{this.stringAtJsonPath("$.employeeId")}}</bsvc:ID>
    </bsvc:Worker_Reference>
    <bsvc:Enter_Time_Off_Entry_Data>
      <bsvc:Time_Off_Entry_ID>{{random.randomUUID()}}</bsvc:Time_Off_Entry_ID>
      <bsvc:Date>{{this.stringAtJsonPath("$.timeOffDate")}}</bsvc:Date>
      <bsvc:Requested>{{this.numberAtJsonPath("$.requestedHours")}}</bsvc:Requested>
      <bsvc:Time_Off_Type_Reference>
        <bsvc:ID bsvc:type="Time_Off_Type_ID">{{this.stringAtJsonPath("$.timeOffTypeId")}}</bsvc:ID>
      </bsvc:Time_Off_Type_Reference>
    </bsvc:Enter_Time_Off_Entry_Data>
  </bsvc:Enter_Time_Off_Data>
  {{/each}}
</bsvc:Import_Time_Off_Request_Event_Batch_Request>
```

### When to Use `random.randomUUID()` vs. a Workday Sequence Generator

Choose between `random.randomUUID()` and a tenant **Sequence Generator** based on downstream auditability and throughput requirements:

| Requirement | Recommended Pattern | Trade-off |
| --- | --- | --- |
| Unattended batch imports (100+ rows per payload) requiring only uniqueness | `random.randomUUID()` | Zero network calls; executes in memory inside loops or templates. |
| Human-readable, sequential audit IDs (such as `O4I-TO-000001`, `O4I-TO-000002`) | Tenant **Sequence Generator** (`Create Sequence Generator` task) | Requires a Workday API call per sequence number unless pre-allocated. |

* * *

## Fixing the `stringAtJsonPath("$.field".toNumber())` Expression Error

When extracting a numeric value stored as a JSON string (such as `"$.latitude": "37.6872"` or `"$.amount": "1250.50"`) and converting it to a `Number` in **Expression Builder**, developers frequently encounter a type mismatch error:

javascript

```
// INVALID — applies .toNumber() to the JSONPath string literal "$.latitude"
data.HttpResponse.response.asJSON().stringAtJsonPath("$.latitude".toNumber())
```

### Why the Error Happens in Expression Builder

In Orchestration Builder’s visual **Expression Builder**, every string node displays an append-function (`fx`) button. Clicking the `fx` button next to the `"$.latitude"` argument attaches `.toNumber()` to the JSONPath path literal itself. At runtime or validation time:

1.  `"$.latitude".toNumber()` attempts to parse the literal characters `"$.latitude"` as a number, which fails because `"$.latitude"` is not a numeric string.
2.  `stringAtJsonPath(path: String)` expects a `String` argument, not the `Number` return type of `.toNumber()`.

### Attaching `.toNumber()` to the Outer `stringAtJsonPath()` Expression

To convert the **extracted JSON value** rather than the path argument, click the outer `fx` append button belonging to the `stringAtJsonPath(...)` function call so `.toNumber()` wraps the entire extraction expression:

javascript

```
// VALID — extracts the string at $.latitude first, then converts it to a Number
data.HttpResponse.response.asJSON().stringAtJsonPath("$.latitude").toNumber()
```

### Choosing Between `.stringAtJsonPath().toNumber()`, `.numberAtJsonPath()`, and `.bigDecimalAtJsonPath()`

Orchestrate’s `Json` instance type enforces strict runtime type checking across its JSONPath extractors:

-   **`stringAtJsonPath(path).toNumber()`**: Use when the JSON payload quotes the number as a string (`{"latitude": "37.6872"}`) and you need an Orchestrate `Number` for arithmetic or numeric loop sorting. If the field can be empty or missing, guard it first:
    
    javascript
    
    ```
    data.HttpResponse.response
      .asJSON()
      .stringAtJsonPathWithDefault("$.latitude", "0")
      .defaultIfBlank("0")
      .toNumber()
    ```
    
-   **`numberAtJsonPath(path)`**: Use only when the JSON payload encodes the value as a native unquoted JSON number (`{"latitude": 37.6872}`). Calling `numberAtJsonPath` on a quoted JSON string throws a runtime exception.
-   **`bigDecimalAtJsonPath(path)`**: Accepts **both** native JSON numbers (`37.6872`) and numbers inside JSON strings (`"37.6872"`), returning a `BigDecimal` suitable for exact decimal and currency calculations.

* * *

## Verifying the Expressions in Orchestration Builder

1.  Open the **Create Values** or **Loop** step in **Orchestration Builder** and switch the expression field to text view (or inspect the function nesting hierarchy) to verify that `.toNumber()` sits outside the closing parenthesis of `stringAtJsonPath("$.latitude")`.
2.  Run the orchestration in **DebugOrchestrations** mode and inspect the **Create Values** step output in the debugger panel to confirm `random.randomUUID()` emits a distinct 36-character UUID per iteration and the numeric variable resolves to type `Number` (or `BigDecimal`).

## Sources checked

-   [Reference: Random Global Functions](https://developer.workday.com/documentation/GUID-1098866b-7bc5-44c2-8c31-c7618c434236)
-   [Reference: Json Member Functions](https://developer.workday.com/documentation/GUID-85d61153-4a66-41e7-ad4f-921b0e9a152e)
-   [Reference: String Member Functions](https://developer.workday.com/documentation/GUID-c22f5c68-87f5-4bd6-ad96-4e0d246e72c3)
-   [Concept: Expression Builder](https://developer.workday.com/documentation/GUID-0a5a2a77-aa2d-4aa2-b733-6ab52588ea6c)

## Related guides

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

-   [### JSONPath Logical Filter Expressions and Wildcard XPaths in Workday Orchestrate Compound JSONPath filter expressions (&&, ||) in Workday Orchestrate fail silently when typographic quotes are pasted or unsupported filter tokens are chained. Learn the supported JSONPath and wildcard XPath syntax and when to replace SOAP launch polling with Trigger Integration.](https://kiweely.com/guides/workday-orchestrate-jsonpath-logical-filters-xpath-wildcards)
-   [### Preventing Duplicate Records on Orchestration Rerun and Concurrent Webhook Triggers in Workday Rerunning a partially failed orchestration or handling two webhook events firing seconds apart can create duplicate records in Workday. Replace report-fetch-delete-create sequences with atomic REST Batch calls (continueOnFailure: false), deterministic reference IDs, or staging queues.](https://kiweely.com/guides/workday-orchestrate-idempotency-concurrent-webhooks-duplicates)
-   [### Why Log to File Turns XML Closing Tags into <// and How to Write #if Conditions in CreateTextTemplate Viewing aggregated XML through a Log to File step in Workday Orchestrate turns every closing tag ‘</’ into ‘<//’ because Log to File defaults its CSV escape character to ‘/’. Use Store Document for XML files, and omit outer parentheses around #if conditions in CreateTextTemplate.](https://kiweely.com/guides/workday-orchestrate-xml-double-slash-log-to-file-if-conditions)
-   [### Sorting JsonKeyValueIterator Collections and Numeric String Values in Workday Orchestrate Loops Workday Orchestrate fails at build time when sorting a JsonKeyValueIterator loop by item.key(), and sorts numeric strings lexicographically (‘1’, ‘1000’, ‘3’). Use a two-loop key extraction pattern for JSON objects and cast string IDs with toNumber() in Loop Sort By.](https://kiweely.com/guides/workday-orchestrate-sort-jsonkeyvalueiterator-numeric-sorting)

### More guides on Orchestrate

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

-   [Why Send Workday RaaS Request fails with ‘Key not found’ (HTTP 202) or times out at 5 minutes](https://kiweely.com/guides/workday-orchestrate-raas-key-not-found-202-5-minute-timeout)
-   [Fixing ‘not a simple type launch parameter (Text, Number, Boolean, Date)’ on blank O4I launch parameters](https://kiweely.com/guides/workday-orchestrate-null-launch-parameter-not-simple-type)
-   [Storing and Migrating External Client CredStore OAuth Credentials and Masked Integration Attributes in Workday Orchestrate](https://kiweely.com/guides/workday-orchestrate-migrate-external-client-credstore-secrets)
-   [Reading the HTTP Response Content-Type Header in Workday Orchestrate](https://kiweely.com/guides/workday-orchestrate-http-response-content-type-header)
-   [Transforming dynamic-key JSON to CSV and grouping flat CSV rows into nested JSON in Orchestrate](https://kiweely.com/guides/workday-orchestrate-dynamic-json-keys-to-csv-grouped-json)
-   [Custom CSV formatting in Workday Orchestrate: Windows CRLF line endings, title rows, and skipping preamble lines](https://kiweely.com/guides/workday-orchestrate-csv-crlf-title-row-skip-header-lines)
-   [Resolving ‘\[StepException\] requirement failed: Input lists must be of the same size’ in createReferenceList](https://kiweely.com/guides/workday-orchestrate-createreferencelist-input-lists-same-size)
-   [Fixing ‘Fast forwarding to correct position’ and 45-minute timeouts in Orchestrate batchLoop](https://kiweely.com/guides/workday-orchestrate-batchloop-paginatedget-fast-forwarding-timeout)

### From the blog on Orchestrate

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

-   [Why Workday Studio Remains Essential in an Orchestrate World](https://kiweely.com/blog/why-workday-studio-still-matters-with-orchestrate)
-   [Debugging Workday Extend apps and orchestrations in kiweely](https://kiweely.com/blog/debugging-workday-extend-apps-orchestrations-kiweely)
-   [Kiweely Roots vs Workday EIB, Studio, and Orchestrate](https://kiweely.com/blog/kiweely-roots-vs-workday-eib-studio-orchestrate)

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