Skip to content
KiweelyKiweelyKiweely

Displaying dynamicColumns in a Workday Extend PMD Grid and Flattening Nested Arrays into Rows

Workday Extend developers often confuse variable child rows with runtime-generated grid columns. This guide covers flattening nested RaaS or REST arrays into grid rows, configuring dynamicColumns with cellTemplates, and rendering arbitrary WQL SELECT fields using map:getKeys().

  • Checked against Workday on
  • Applies to Workday Extend
  • 3 min read
  • Published
  • By Kiweely
On this page

Distinguishing Variable Child Rows from dynamicColumns in a PMD grid

In Workday Extend Presentation Metadata (PMD), columns and dynamicColumns on a grid widget are mutually exclusive. Before configuring dynamicColumns, determine whether the column headers change at runtime or whether a parent record simply contains a variable number of child items.

When a Workday Custom Report exposed as Reports-as-a-Service (RaaS) or a REST endpoint returns a parent object with a nested multi-instance group—such as a Worker with a nested Dependents_group array—the grid layout still has two fixed columns (Worker and Dependent) and a dynamic number of rows. Using dynamicColumns for nested parent-child arrays will not expand child records into vertical rows. Instead, flatten the nested array in a PMD script function and bind the resulting list to rows on a standard grid with static columns.

Reserve dynamicColumns for grids where the column definitions (header labels, column IDs, data types, and field paths) come from an endpoint or runtime metadata list, or use indexed map:getKeys() column bindings when rendering ad-hoc Workday Query Language (WQL) results whose SELECT attributes are unknown at design time.

Pattern 1: Flattening Nested Parent-Child Arrays into Grid Rows

Consider a RaaS JSON payload where each Report_Entry item represents a worker and contains a Dependents_group array of varying length:

json
{
  "Report_Entry": [
    {
      "Worker": "Alex Rivera",
      "Dependents_group": [
        { "Dependent": "Megan McNeil" },
        { "Dependent": "Pat McNeil" }
      ]
    },
    {
      "Worker": "Steve Morgan",
      "Dependents_group": [
        { "Dependent": "Catherine Morgan" },
        { "Dependent": "Elizabeth Morgan" },
        { "Dependent": "Josh Morgan" }
      ]
    }
  ]
}

A PMD grid renders one row per element in the list bound to rows. To display each dependent on its own row while showing the worker’s name only on the first row of each group, define a helper function in the PMD script block that iterates through both the outer Report_Entry array and the inner Dependents_group array:

javascript
"script": "<%
  var buildGridRows = function() {
    var result = [];
    var reportEntries = raasEndpoint.Report_Entry ?? [];
    for (var entry : reportEntries) {
      var dependents = entry.Dependents_group ?? [];
      if (empty dependents) {
        result.add({
          'Worker': entry.Worker,
          'Dependent': ''
        });
      } else {
        for (var i = 0; i < dependents.size(); i++) {
          var workerName = (i == 0) ? entry.Worker : '';
          result.add({
            'Worker': workerName,
            'Dependent': dependents[i].Dependent
          });
        }
      }
    }
    return result;
  };
%>"

Bind rows on the grid directly to <% buildGridRows() %> and reference the flattened properties through rowVariableName:

json
{
  "type": "grid",
  "id": "workerDependentGrid",
  "label": "Worker Dependents",
  "rows": "<% buildGridRows() %>",
  "rowVariableName": "row",
  "doNotAdd": true,
  "doNotRemove": true,
  "columns": [
    {
      "type": "column",
      "columnId": "workerCol",
      "label": "Worker",
      "cellTemplate": {
        "type": "text",
        "value": "<% row.Worker %>"
      }
    },
    {
      "type": "column",
      "columnId": "dependentCol",
      "label": "Dependent",
      "cellTemplate": {
        "type": "text",
        "value": "<% row.Dependent %>"
      }
    }
  ]
}

Pattern 2: Configuring dynamicColumns with cellTemplates

When the columns themselves must be generated from a metadata list—for example, when multiple text, date, or boolean columns share a set of reusable cell templates or when an endpoint supplies the column list—use the dynamicColumns child tag together with cellTemplates[] on the grid.

Every dynamicColumns configuration requires six attributes (id is optional and used only for debugging):

  • columns: A binding to a list of column metadata objects.
  • columnVariableName: The iterator variable name representing each item in columns.
  • columnId: Binding to the unique identifier attribute on columnVariableName.
  • label: Binding to the column header title on columnVariableName.
  • templateId: Binding to the type key on columnVariableName that matches a templateId entry in the grid’s cellTemplates[] array.
  • attributeName: Binding to the field name or nested path in each row object (for example, 'descriptor' or 'primaryJob.supervisoryOrganization.descriptor').
json
{
  "type": "grid",
  "id": "gridWithDynamicColumns",
  "label": "Workers Directory",
  "rowVariableName": "row",
  "rows": "<% workersEndpoint.data ?? [] %>",
  "dynamicColumns": {
    "type": "dynamicColumns",
    "columns": "<%
      [
        {
          'name': 'Worker Name',
          'id': 'descriptorCol',
          'type': 'stringTemplate',
          'dataField': 'descriptor'
        },
        {
          'name': 'Supervisory Organization',
          'id': 'supOrgCol',
          'type': 'stringTemplate',
          'dataField': 'primaryJob.supervisoryOrganization.descriptor'
        }
      ]
    %>",
    "columnVariableName": "aColumn",
    "columnId": "<% aColumn.id %>",
    "label": "<% aColumn.name %>",
    "templateId": "<% aColumn.type %>",
    "attributeName": "<% aColumn.dataField %>"
  },
  "cellTemplates": [
    {
      "type": "cellTemplate",
      "templateId": "stringTemplate",
      "template": {
        "type": "text"
      }
    }
  ]
}

Because attributeName automatically binds the cell widget’s value to the corresponding property in rows, the text widget inside cellTemplates does not declare a manual value binding.

Pattern 3: Rendering Arbitrary WQL Columns with map:getKeys()

When building a dynamic WQL query runner or report previewer where the attributes in the SELECT clause are not known until the query executes, you can inspect the keys of the first returned row (wqlResult[0]) using map:getKeys(). Define a set of indexed column slots inside a dynamicSection pod and control each column’s presence with a render condition checking map:getKeys(data.wqlResult[0]).size() > index:

json
{
  "type": "grid",
  "id": "queryResultsGrid",
  "label": "Query Results",
  "render": "<% !empty data.wqlResult %>",
  "enabled": false,
  "rows": "<% data.wqlResult %>",
  "rowVariableName": "queryResult",
  "doNotAdd": true,
  "doNotRemove": true,
  "selectionEnabled": false,
  "columns": [
    {
      "type": "column",
      "id": "col0",
      "columnId": "0",
      "label": "<% map:getKeys(data.wqlResult[0]).get(0) %>",
      "render": "<% map:getKeys(data.wqlResult[0]).size() > 0 %>",
      "cellTemplate": {
        "type": "text",
        "value": "<% queryResult[map:getKeys(data.wqlResult[0]).get(0)] %>"
      }
    },
    {
      "type": "column",
      "id": "col1",
      "columnId": "1",
      "label": "<% map:getKeys(data.wqlResult[0]).get(1) %>",
      "render": "<% map:getKeys(data.wqlResult[0]).size() > 1 %>",
      "cellTemplate": {
        "type": "text",
        "value": "<% queryResult[map:getKeys(data.wqlResult[0]).get(1)] %>"
      }
    }
  ]
}

When a user triggers a deferred WQL endpoint via a pageActionButton, call resultsDynamicSection.setData({'wqlResult': response.data}) to refresh the dynamicSection container. The grid evaluates map:getKeys(data.wqlResult[0]), sets each column header to the WQL field alias, and hides any unused column slots where size() <= index.

How to Verify in the Tenant

  1. Deploy the updated PMD page to your Workday Extend development tenant using wdcli or App Builder.
  2. For nested parent-child arrays (Pattern 1), open the page and confirm that workers with multiple dependents render across consecutive rows with the worker name displayed on the first row of each group and blank worker cells on subsequent dependent rows.
  3. For dynamicColumns (Pattern 2), inspect the page in the tenant to verify that every entry in the columns metadata list matches a valid templateId in cellTemplates[] and renders the nested attributeName path without schema validation errors in View Application Logs.
  4. For dynamic WQL grids (Pattern 3), execute queries with different numbers of SELECT fields and confirm that only the active column slots render and populate their headers from map:getKeys().

Sources checked

Related guides

All guides

Let Workday check the work.

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

Get the next guide in your inbox.

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

We’ll email you once to confirm. Unsubscribe in one click from any issue.