---
title: "Prevent Duplicate Records & Webhook Races in Orchestrate"
description: "Prevent duplicate Custom Object and Workday records when rerunning a failed orchestration or handling concurrent webhook triggers in Workday Orchestrate."
url: https://kiweely.com/guides/workday-orchestrate-idempotency-concurrent-webhooks-duplicates
---

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

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

## Why Concurrent Webhook Triggers Create Duplicate Custom Object Records

A common integration design for syncing external webhook events into a Workday Custom Object or Extend Model Business Object uses a four-step **Fetch -> Delete -> Create** sequence inside an orchestration:

1.  Receive the incoming webhook JSON payload.
2.  Execute a Custom Report (RaaS) or WQL query to check whether a Custom Object record already exists for that business key.
3.  If a record exists, delete the existing Custom Object instance by its Workday ID (`WID`).
4.  Create a new Custom Object instance with the updated payload.

When two webhook events for the same record fire within a few seconds of each other, each webhook spawns an independent, parallel orchestration instance. Because Workday Orchestrate executes webhook-triggered runs concurrently without a cross-instance mutex lock, a classic time-of-check to time-of-use (TOCTOU) race condition occurs:

| Timestamp | Webhook Instance 1 | Webhook Instance 2 | Tenant State |
| --- | --- | --- | --- |
| `05:57:03` | Runs Custom Report (finds `WID_A`) | — | `WID_A` exists |
| `05:57:06` | Deletes `WID_A` | — |  **0 records exist** |
| `05:57:07` | Preparing create payload... | Runs Custom Report (**finds 0 records**) |  **0 records exist** |
| `05:57:14` | Creates new record `WID_B` | Creates new record `WID_C` |  **Duplicate records (`WID_B` and `WID_C`)** |

In addition, custom reports and WQL data sources backed by search indexes can experience a multi-second indexing lag after a record is created, causing a second webhook arriving immediately after creation to see zero existing rows and insert a duplicate.

* * *

## Eliminating Webhook Race Conditions with Upserts or Staging Queues

Never use a `Delete -> Recreate` pattern for records updated by real-time webhooks. Use one of three concurrency-safe patterns in Workday Orchestrate:

### Pattern 1: Update in Place (`PATCH` / `PUT`) Using a Deterministic Key

Instead of deleting the existing Custom Object instance and creating a new `WID`, keep the existing instance and update its fields in place:

-   **For Workday Custom Objects (`Custom_Object` REST or `Manage_Custom_Object` Web Service):** If a record already exists for the worker or business object (or if the Custom Object is single-instance per worker), send a `PUT` or `PATCH` (or `Put_Custom_Object` SOAP call) targeting the existing `WID` or deterministic reference ID. Even if two webhooks execute `PUT`/`PATCH` seconds apart, both update the same underlying object instance rather than creating a second row.
-   **For Extend Model Business Objects (MBOs):** Store a deterministic external business key on the MBO. Query the MBO directly via its transactional REST collection endpoint (`GET /apps/<app>/v1/<bo>?<filter>`) or maintain a 1:1 mapping, and execute `PATCH /apps/<app>/v1/<bo>/{id}` when the record exists.

### Pattern 2: Decouple Webhook Ingestion from Processing via an Append-Only Staging Object

When a webhook must perform complex multi-record updates that cannot be expressed as a single idempotent `PATCH`:

1.  **Webhook Orchestration (Fast Append-Only):** The webhook-triggered orchestration performs **no** report lookups or deletes. It immediately inserts the raw webhook event payload, external event timestamp, and correlation key into an append-only **Webhook Event Queue** Extend Business Object with `status = "PENDING"`.
2.  **Scheduled Processor Orchestration (Single-Threaded Deduplication):** A scheduled O4I orchestration runs every 5–15 minutes, fetches all `"PENDING"` queue records grouped by correlation key (`Batch Loop` with `Group By`), applies only the latest timestamped payload for each business key in sequential order, and marks the queued rows `"PROCESSED"`.

* * *

## Preventing Duplicate Records When Rerunning a Failed Multi-Step Orchestration

When an orchestration executes a sequence of dependent Workday API calls—for example, Step 1 creates a Position (`Create_Position_Request`), Step 2 assigns costing allocations, and Step 3 updates supervisory organization metadata—a failure in Step 3 leaves Step 1’s Position committed in the tenant. Simply rerunning the failed orchestration from the beginning creates a duplicate Position.

### 1\. Atomic All-or-Nothing Execution with the Workday REST Batch API

If the multi-step workflow calls Workday REST or Extend Model Object REST APIs that support the `/batch` endpoint, combine the dependent operations into a single **Send Workday API Request** batch payload with `"continueOnFailure": false`:

-   When `"continueOnFailure": false` is set on a supported batch request, a validation error on a later item aborts the batch so partial state is not left behind.

### 2\. Compensating Rollback (Rescind) in Downstream Error Handlers

For Workday SOAP APIs where each web service call commits its own transaction immediately:

1.  Capture the created `Position_Reference` WID (or `Event_Reference` WID) from Step 1 in a **Create Values** step (`CreatedPositionWid`).
2.  Attach a local **Error Handler** to Step 2 and Step 3.
3.  Inside the Error Handler, invoke the corresponding Workday rescind or cancel web service (`Cancel_Event` / `Rescind_Business_Process` or delete operation) passing `data.CreatedPositionWid.wid` before propagating the error, returning the tenant to a clean pre-run state.

### 3\. Step-Level Checkpoint State Tracking for Idempotent Reruns

If automatic rescind is not desired because an administrator needs to inspect the failure and rerun:

1.  Pass a deterministic **External Reference ID** (such as `Position_ID` derived from the upstream requisition or source transaction ID instead of an auto-generated ID) into Step 1.
2.  Before executing Step 1, query Workday by that deterministic `Position_ID` (or check a tracking Business Object keyed by the source transaction ID).
3.  Use a **Branch on Conditions** step: if the `Position_ID` already exists from a prior partial run, skip Step 1, bind its existing `WID` to `CreatedPositionWid`, and resume directly at Step 2.

* * *

## Verifying Concurrency and Rerun Safety in Your Tenant

1.  Trigger two concurrent executions of your webhook orchestration within 2 seconds using the same external correlation key and inspect the target Custom Object or Business Object via **View Custom Object** or WQL to confirm only a single record exists.
2.  Force a downstream step failure in your multi-step orchestration (for example, by passing an invalid reference ID to Step 2), verify that either the Error Handler rescinds Step 1 or a subsequent rerun skips Step 1 using the deterministic `Position_ID`, and confirm zero duplicate positions are created.

## Sources checked

-   [Handle Errors](https://developer.workday.com/documentation/GUID-13ff2639-de8c-43c4-932a-e109fd3c8567)
-   [Reference: Send Workday API Request](https://developer.workday.com/documentation/GUID-43efaf69-686f-4372-a0a7-5238ead1a2a7)
-   [Concept: Orchestration Processes](https://developer.workday.com/documentation/GUID-3274e8db-46ed-4c0b-bedc-e36948e26613)
-   [Reference: Trigger Integration](https://developer.workday.com/documentation/GUID-cb68f51e-56ce-4159-b450-5b5ede1caf59)

## Related guides

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

-   [### 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.](https://kiweely.com/guides/workday-orchestrate-randomuuid-stringatjsonpath-tonumber)
-   [### Storing and Migrating External Client CredStore OAuth Credentials and Masked Integration Attributes in Workday Orchestrate Store external OAuth 2.0 credentials in Workday’s External Client CredStore and non-OAuth credentials in masked Integration Attributes (Password display option). After promoting an app or refreshing a Sandbox tenant from Production, update the target tenant’s CredStore and attribute values.](https://kiweely.com/guides/workday-orchestrate-migrate-external-client-credstore-secrets)
-   [### 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)
-   [### Waiting for Import\_Payroll\_Input\_Request Background Processes at Scale in Workday Orchestrate Calling Import\_Payroll\_Input\_Request in Workday Orchestrate spawns an asynchronous background process. Instead of polling WQL in a fixed-iteration loop, invoke the import inside a child O4I integration via Trigger Integration, which waits for all spawned background jobs to complete before resuming.](https://kiweely.com/guides/workday-orchestrate-wait-background-process-import-payroll-input)

### More guides on Orchestrate

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

-   [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)
-   [Overcoming ‘Message length should be lesser than 1MB in size’ and ‘Orchestration is too large to be saved’](https://kiweely.com/guides/workday-orchestrate-1mb-message-limit-too-large-to-save)
-   [Handling Silent GraphQL Errors in PMD and Orchestrate When HTTP Status Returns 200 OK](https://kiweely.com/guides/workday-graphql-http-200-silent-mutation-errors)
-   [Avoiding the 25-Second Synchronous Timeout When an Extend Page Calls External LLM APIs Through Orchestrate](https://kiweely.com/guides/workday-extend-async-orchestration-llm-timeout)

### From the blog on Orchestrate

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

-   [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)
-   [Orchestrate, an iPaaS, or Kiweely Roots](https://kiweely.com/blog/orchestrate-ipaas-or-kiweely-roots)

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