---
title: "Split New and Modified PMD Grid Rows for Bulk POST & PATCH"
description: "Filter new and existing rows in an editable Workday Extend PMD grid using onRowAdd and onSend so bulk POST and PATCH endpoints do not duplicate records."
url: https://kiweely.com/guides/workday-extend-pmd-split-new-modified-grid-rows-bulk-post-patch
---

# Splitting New and Existing PMD Grid Rows in onSend for Bulk POST and PATCH Without Duplicating Records

When an editable PMD grid with isArrayOutBinding: true is bound to both POST ?bulk=true and PATCH ?bulk=true endpoints, sending unfiltered self.data duplicates existing rows. Tag newly added rows in onRowAdd or check empty(row.id) and filter self.data inside each endpoint’s onSend script.

-   **Checked** against Workday on November 6
-   Applies to **Workday Extend**
-   2 min read
-   Published November 6
-   By Kiweely

## Why binding an editable grid to both bulk `POST` and `PATCH` duplicates rows

On a Workday Extend edit page where a `grid` widget (`"isArrayOutBinding": true`) loads existing Model Business Object (`MBO`) records on page open and also allows the user to click **Add** to insert new rows, submitting the page requires two separate bulk REST calls:

-   `POST /<collectionName>?bulk=true` to create the newly added rows.
-   `PATCH /<collectionName>?bulk=true` to update the existing rows that already have a Business Object `id`.

If you bind the grid’s columns (`valueOutBinding`) to both outbound endpoints (`revokeUserAccessPOST:data` and `revokeUserAccessPATCH:data`) and leave `"onSend": "<% return self.data; %>"` on both endpoints, Workday sends the **entire** grid array to `POST ?bulk=true` and the **entire** grid array to `PATCH ?bulk=true`. As a result, if the grid starts with 1 existing row and the user adds 1 new row, `POST ?bulk=true` creates 2 new records (duplicating the existing row), increasing the total record count in the Business Object from 1 to 3 instead of 2.

## Step 1: Track which grid rows are newly added vs. loaded from the Business Object

To separate new rows from existing rows cleanly, include two hidden columns (or fields inside a `panelList`) on the grid:

1.  `recordId` (`columnId: "idCol"`): Bound to `<% row.id %>` (the existing Business Object instance `id` returned by the inbound `GET` or `WQL` endpoint) with `"valueOutBinding"` mapped to the outbound payload’s `id` property.
2.  `isNewRow` (`columnId: "isNewRowCol"`, `"visible": false`): Initialized to `<% empty(row.id) ? true : false %>` and explicitly set to `true` inside the grid’s `onRowAdd` event (or `onPanelAdd` on a `panelList`).

json

```
{
  "type": "grid",
  "id": "userAccessGrid",
  "label": "User Access Records",
  "rows": "<% existingAccessRecords.data ?? [] %>",
  "rowVariableName": "row",
  "isArrayOutBinding": true,
  "onRowAdd": "<%
    var rows = self.getRows();
    var addedRow = rows[rows.size() - 1];
    addedRow.childrenMap.isNewRowCell.setValue(true);
  %>",
  "columns": [
    {
      "type": "column",
      "columnId": "idCol",
      "label": "ID",
      "visible": false,
      "cellTemplate": {
        "type": "text",
        "id": "recordIdCell",
        "value": "<% row.id ?? '' %>",
        "valuesOut": [
          {
            "value": "<% self.value %>",
            "valueOutBinding": "revokeUserAccessPATCH:data[].id"
          }
        ]
      }
    },
    {
      "type": "column",
      "columnId": "isNewRowCol",
      "label": "Is New",
      "visible": false,
      "cellTemplate": {
        "type": "checkBox",
        "id": "isNewRowCell",
        "value": "<% empty(row.id) ? true : false %>",
        "valuesOut": [
          {
            "value": "<% self.value %>",
            "valueOutBinding": "revokeUserAccessPOST:data[].isNewRow"
          },
          {
            "value": "<% self.value %>",
            "valueOutBinding": "revokeUserAccessPATCH:data[].isNewRow"
          }
        ]
      }
    },
    {
      "type": "column",
      "columnId": "workerCol",
      "label": "Worker",
      "cellTemplate": {
        "type": "instanceList",
        "id": "workerCell",
        "instances": "<% workersList.data %>",
        "selectedValuesAndDescriptors": "<% empty(row.worker) ? [] : [row.worker] %>",
        "valuesOut": [
          {
            "value": "<% empty(self.value) ? null : {'id': self.value[0]} %>",
            "valueOutBinding": "revokeUserAccessPOST:data[].worker"
          },
          {
            "value": "<% empty(self.value) ? null : {'id': self.value[0]} %>",
            "valueOutBinding": "revokeUserAccessPATCH:data[].worker"
          }
        ]
      }
    },
    {
      "type": "column",
      "columnId": "reasonCol",
      "label": "Revoke Reason",
      "cellTemplate": {
        "type": "text",
        "id": "reasonCell",
        "value": "<% row.reason ?? '' %>",
        "valuesOut": [
          {
            "value": "<% self.value %>",
            "valueOutBinding": "revokeUserAccessPOST:data[].reason"
          },
          {
            "value": "<% self.value %>",
            "valueOutBinding": "revokeUserAccessPATCH:data[].reason"
          }
        ]
      }
    }
  ]
}
```

## Step 2: Filter `self.data` in `onSend` and strip the helper flag

Inside the `outboundEndPoints` array, configure `onSend` on `revokeUserAccessPOST` to keep only items where `isNewRow == true`, and configure `onSend` on `revokeUserAccessPATCH` to keep only items where `isNewRow != true` and `id` is non-empty.

Because the Model Business Object schema does not have a field named `isNewRow`, strip the temporary `isNewRow` key when building the final array of row objects in `onSend` (otherwise the Extend REST API will reject the request with `400 Bad Request: unrecognized field: isNewRow`). In addition, guard each endpoint with `"exclude"` so Workday does not send an empty `{ "data": [] }` bulk request when the user only edits existing rows or only adds new rows:

json

```
{
  "outboundData": {
    "outboundEndPoints": [
      {
        "name": "revokeUserAccessPOST",
        "baseUrlType": "app",
        "url": "revokeUserAccesses?bulk=true",
        "httpMethod": "POST",
        "authType": "sso",
        "exclude": "<%
          var rows = userAccessGrid.getRows();
          var hasNew = false;
          for (var r : rows) {
            if (r.childrenMap.isNewRowCell.value == true) {
              hasNew = true;
            }
          }
          return !hasNew;
        %>",
        "onSend": "<%
          var rawRows = self.data.data ?? [];
          var postRows = [];
          for (var item : rawRows) {
            if (item.isNewRow == true) {
              postRows.add({
                'worker': item.worker,
                'reason': item.reason
              });
            }
          }
          return { 'data': postRows };
        %>",
        "failOnStatusCodes": [
          { "code": 400 },
          { "code": 401 },
          { "code": 403 },
          { "code": 404 },
          { "code": 500 }
        ]
      },
      {
        "name": "revokeUserAccessPATCH",
        "baseUrlType": "app",
        "url": "revokeUserAccesses?bulk=true",
        "httpMethod": "PATCH",
        "authType": "sso",
        "exclude": "<%
          var rows = userAccessGrid.getRows();
          var hasExisting = false;
          for (var r : rows) {
            if (r.childrenMap.isNewRowCell.value != true && !empty(r.childrenMap.recordIdCell.value)) {
              hasExisting = true;
            }
          }
          return !hasExisting;
        %>",
        "onSend": "<%
          var rawRows = self.data.data ?? [];
          var patchRows = [];
          for (var item : rawRows) {
            if (item.isNewRow != true && !empty(item.id)) {
              patchRows.add({
                'id': item.id,
                'worker': item.worker,
                'reason': item.reason
              });
            }
          }
          return { 'data': patchRows };
        %>",
        "failOnStatusCodes": [
          { "code": 400 },
          { "code": 401 },
          { "code": 403 },
          { "code": 404 },
          { "code": 500 }
        ]
      }
    ]
  }
}
```

## How to verify the fix in your tenant

1.  Seed 1 existing record into your Model Business Object and open the edit page so the grid renders 1 initial row.
2.  Modify a field on row 1, click **Add** on the grid to insert row 2, populate row 2, and submit the page.
3.  Run **View WQL Query Result** (`SELECT workdayID, worker, reason FROM <app>_revokeUserAccesses`) and confirm that the Business Object contains exactly 2 records—the updated original record (same `workdayID`) and 1 newly created record—with no duplicate copy of row 1.

## Sources checked

-   [Concept: grid](https://developer.workday.com/documentation/tgx1652476064414)
-   [grid](https://developer.workday.com/documentation/zmz1518211268000)
-   [outboundEndPoints](https://developer.workday.com/documentation/kdd1594147277519)
-   [outboundDataURI](https://developer.workday.com/documentation/yzz1530025276777)
-   [Reference: PMD Scripting Events](https://developer.workday.com/documentation/tgy1581495452394)

## Related guides

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

-   [### Handling Silent GraphQL Errors in PMD and Orchestrate When HTTP Status Returns 200 OK Workday Graph API endpoints return HTTP 200 OK even when a query or mutation fails with an S21 or validation error inside the JSON errors array. Inspect $.errors explicitly in Orchestrate and verify that your .amd base URL version matches Graph API Explorer.](https://kiweely.com/guides/workday-graphql-http-200-silent-mutation-errors)
-   [### Clearing Single-Instance Relationships to Null and Binding createdBy with graph:createId() in Graph API Workday Graph API mutations require nested IdentifierInput objects for single-instance relationships like createdBy—which you can generate cleanly in PMD with graph:createId(id). To clear an existing single-instance relationship back to null, use the Model Business Object REST PUT or PATCH API.](https://kiweely.com/guides/workday-graphql-clear-single-instance-null-graph-createid)
-   [### 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)
-   [### 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)

### More guides on Extend apps and pages

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

-   [Fixing radioGroup Options Disappearing When selectedValues Is Empty and Disabling Specific Options in Workday Extend PMD](https://kiweely.com/guides/workday-extend-pmd-radiogroup-options-disappear-disable-specific-items)
-   [Why a RaaS Endpoint Returns HTTP 200 with data as null in PMD and How to Surface SOAP Fault Messages](https://kiweely.com/guides/workday-extend-pmd-raas-report-entry-null-soap-fault-http-200)
-   [Deleting Selected Grid Rows and Fixing Parallel Multi-Instance Arrays Collapsing on Edit Pages in Workday Extend PMD](https://kiweely.com/guides/workday-extend-pmd-grid-delete-selected-rows-parallel-arrays-collapse)
-   [Displaying dynamicColumns in a Workday Extend PMD Grid and Flattening Nested Arrays into Rows](https://kiweely.com/guides/workday-extend-pmd-dynamic-grid-columns-flattening-arrays)
-   [Conditional Page Routing on Load, multiStepLayout vs. tabBar Navigation, and flowVariables Payload Limits in Workday Extend PMD](https://kiweely.com/guides/workday-extend-pmd-conditional-page-routing-tabbar-flowvariables-limits)
-   [Clearing Grid Cell Validation Errors on onChange and Blocking Page Save on pageActionButton Failure in Workday Extend PMD](https://kiweely.com/guides/workday-extend-pmd-clear-grid-cell-error-pageactionbutton-block-save)
-   [Resolving “Tenant mapping not found (OP-4008)”, EU vs. US Regional Base URL 401 Errors, and client\_secret\_basic in Workday Extend OAuth 2.0](https://kiweely.com/guides/workday-extend-oauth-tenant-mapping-op-4008-eu-base-url-client-secret-basic)
-   [Working Around the 10-Relationship Limit on a Workday Extend Model Business Object (MCBO) Using a Helper Object](https://kiweely.com/guides/workday-extend-mcbo-10-single-instance-relationship-limit-helper-bo)

### From the blog on Extend apps and pages

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

-   [Desktop apps for Extend and Studio](https://kiweely.com/blog/desktop-app-for-workday-extend-and-studio-developers)
-   [Workday Opened Extend to Individual Developers. Here’s What It Changes](https://kiweely.com/blog/workday-opens-extend-to-individual-developers)
-   [Debugging Workday Extend web services: Postman vs. kiweely](https://kiweely.com/blog/debugging-workday-extend-web-services-postman-vs-kiweely)

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