Blog

Process Orchestration

KTA: Adding the normal form table rows into Capture Table

Challenge:

We might get the requirement to update the selected row of the normal form table to Capture table. Eg:-  Invoice line lookup table will have more records. We just need to add the selected records or all records from the lookup table to the actual capture table.

Solution:

The below code will help to achieve this. It states getting all the record from the lookup table and place it to capture table.

var sourceSelectedRowCount=new Array();
var targetTableColumnNamesArray=new Array();
var paramsDataArray=new Array();

var lookupTable= thisForm.controlManager.getControlByName(‘tblTemp’);
var rowCount = lookupTable.store.getCount();
sourceSelectedRowCount[0]= rowCount;
var valuesArray= new Array(rowCount)

var currRow = 0;
var table=thisForm.controlManager.getControlByName(‘LineItems’);

var arrParams1=’LineItems.PONumber’;
var arrParams1Data= new Array(rowCount )
var arrParams2=’LineItems.Description’;
var arrParams2Data= new Array(rowCount )

lookupTable.getStore().getRange().forEach(function (row) {
arrParams1Data[currRow] = row.get(‘Column1’)
arrParams2Data[currRow] = row.get(‘Column2’)
currRow += 1;
})

Forms.Common.Common.GetEachTargetColumnData(arrParams1,sourceSelectedRowCount,targetTableColumnNamesArray,paramsDataArray,arrParams1Data);

Forms.Common.Common.GetEachTargetColumnData(arrParams2,sourceSelectedRowCount,targetTableColumnNamesArray,paramsDataArray,arrParams2Data);

valuesArray=Forms.Common.Common.GetAddRowActionDataForCaptureTable(sourceSelectedRowCount,targetTableColumnNamesArray,paramsDataArray);

var data={‘columnNames’:targetTableColumnNamesArray,’fieldNames’:targetTableColumnNamesArray,’values’:valuesArray,’replaceData’:false};

table.fireEvent(‘ta_add_populated_table_rows’,table,data)