Skip to content

Merge Two Columns in a Table

Legacy (Process Designer)

This page describes a script for the Modify Your Metadata activity of Process Designer. It was replaced by the Custom Step in Workflow. The script may not run as a Custom Step without changes. For new work, use the Custom Step reference.

This example shows how to merge the first two columns in a Table.

var workingTable = builder.ConvertTableFieldToTableArray(batch.Metadata['Index']['TableField']);
var targetIndex = 0;
var toMergeIndex = 1;
//check to make sure table has enough columns
if (workingTable[0].length >= toMergeIndex) {
    for (var i = 0; i < workingTable.length; i++) {
        //Remove merge column and add it to the target column
        workingTable[i][targetIndex] += workingTable[i].splice(toMergeIndex, 1);
    }
    builder.SetDocumentMetadata(batch.Documents[0].DocumentId, 'Index', 'TableField', builder.ConvertTableArrayToTableField(workingTable));
}