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:
{
"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:
"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:
{
"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 incolumns.columnId: Binding to the unique identifier attribute oncolumnVariableName.label: Binding to the column header title oncolumnVariableName.templateId: Binding to the type key oncolumnVariableNamethat matches atemplateIdentry in the grid’scellTemplates[]array.attributeName: Binding to the field name or nested path in each row object (for example,'descriptor'or'primaryJob.supervisoryOrganization.descriptor').
{
"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:
{
"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
- Deploy the updated PMD page to your Workday Extend development tenant using
wdclior App Builder. - 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.
- For
dynamicColumns(Pattern 2), inspect the page in the tenant to verify that every entry in thecolumnsmetadata list matches a validtemplateIdincellTemplates[]and renders the nestedattributeNamepath without schema validation errors in View Application Logs. - For dynamic WQL grids (Pattern 3), execute queries with different numbers of
SELECTfields and confirm that only the active column slots render and populate their headers frommap:getKeys().