Dynamically Set Table Column Headers in Human in the Loop Approval Form

Dynamically Set Table Column Headers in Human in the Loop Approval Form

Notes
Problem Statement:

When using the Human-in-the-Loop (HITL) plugin, the approval template contains a table field with three columns. The workflow retrieves table data dynamically from a source and needs to display all retrieved rows on the AutomationEdge UI.

Additionally, the first row of the retrieved data needs to be used as the table column headers instead of being displayed as a normal data row.

When the HITL step is configured with "Use Template Metadata Defined at Server", the table is displayed using the metadata defined in the approval template, and the column headers cannot be modified dynamically at runtime.

Warning
Root Cause:

The "Use Template Metadata Defined at Server" option uses the table metadata defined in the approval template on the AutomationEdge server.

As a result:

  • The table column metadata is fixed based on the approval template.

  • Column displayName values cannot be dynamically modified at runtime.

  • The first row retrieved from the source is treated as normal table data rather than being used as the column headers.

Idea
Resolution :

To dynamically modify the table column headers, configure the HITL step to use:

"Use Server Compatible Template Generated at Runtime"

With this option, the workflow must provide the required table metadata in the server-compatible JSON format at runtime.

The displayName property of each table column can then be dynamically populated based on the retrieved data.

Sample Runtime Metadata:

The following is an example of server-compatible JSON metadata:

[
{
"key": "MEMI_CASHBACK_KEY",
"displayName": "MEMI REPORT",
"type": "table",
"value": null,
"columns": [
{
"key": "Sr_No",
"displayName": "Sr_No",
"uiControl": "label"
},
{
"key": "Particulars",
"displayName": "Particulars",
"uiControl": "label"
},
{
"key": "BTBL_Recon",
"displayName": "BTBL_Recon(108)",
"uiControl": "label"
}
],
"rows": [
{
"Sr_No": {
"value": "A"
},
"Particulars": {
"value": "NCE/LCE Subvention Amount"
},
"BTBL_Recon": {
"value": "0"
}
},
{
"Sr_No": {
"value": "B"
},
"Particulars": {
"value": "Cashback Amount"
},
"BTBL_Recon": {
"value": "0"
}
},
{
"Sr_No": {
"value": "C"
},
"Particulars": {
"value": "Deferred Discount - OEM Funded"
},
"BTBL_Recon": {
"value": "0"
}
}
]
}
]

In this configuration, the displayName values of the table columns can be dynamically generated based on the retrieved data.

For example:

Column Key       Dynamic Display Name
-------------------------------------
Sr_No Sr_No
Particulars Particulars
BTBL_Recon BTBL_Recon(108)

Important Note:

The workflow must generate and pass the metadata in the expected server-compatible JSON structure when using the runtime metadata option.

If the metadata structure is not compatible with the AutomationEdge server format, the HITL task may not display the expected table data.

Verification :

The behavior was verified with both metadata options:

Metadata OptionResult


Use Template Metadata Defined at Server              The table is displayed using the metadata configured in the approval template. Dynamic column headers are not supported.


Use Server Compatible Template Generated at Runtime             Table metadata and column displayName values can be dynamically generated at runtime.

During testing, the expected output was generated successfully when "Use Template Metadata Defined at Server" was selected.

Info
Recommendation:

Use "Use Server Compatible Template Generated at Runtime" when the table structure or column display names need to be dynamically modified during workflow execution.

A sample workflow implementing this approach can be used as a reference. The workflow should be reviewed and adapted according to the customer's existing implementation and data structure.