Hi Community,
I am facing an issue which is related to SectionActions Button for sending multiple records. I need to send some records (out of all selected records) to a business process in an array after filtering with esq inside section edit page.
Issue: The filtered Id's are not being pushed into array correctly. Means when we explore the array, the values are there but when we try to print or send we get initial value of that array (i.e. empty string or null).
getSectionActions: function() {
var actionMenuItems = this.callParent(arguments);
actionMenuItems.addItem(this.getButtonMenuItem({
Type: "Terrasoft.MenuSeparator",
Caption: ""
}));
actionMenuItems.addItem(this.getButtonMenuItem({
"Caption": {bindTo: "Resources.Strings.AMDAssignMultipleRecords"},
"Click": {bindTo:"runCustomProcess"},
"IsEnabledForSelectedAll": true
}));
return actionMenuItems;
},
runCustomProcess: function(){
if(this.get("SelectedRows") == "" || this.get("SelectedRows") == undefined){
this.showInformationDialog("Please select records for batch process!");
}
else{
var selectedRows = this.get("SelectedRows");
console.log("Selected records : ", selectedRows);
var recordsnumber = selectedRows.length;
var resIdRows=[];
var resIdForArray="";
selectedRows.forEach(fnProgramABCArray);
console.log("Selected ABC records : ", resIdRows);
var selectedOrder = resIdRows.toString();
console.log("selectedOrder: ", selectedOrder);
var args = {
sysProcessName: "AMDProcess_BatchAssignments",
parameters: {
SelectedRowsCol: selectedOrder,
NoOfRes: recordsnumber
},
};
ProcessModuleUtilities.executeProcess(args);
}
function fnProgramABCArray(item){
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "AMDTestPlans" });
esq.addColumn("AMDStatus");
esq.addColumn("AMDProgram");
esq.filters.addItem(esq.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, "Id", item));
esq.getEntityCollection(function (result) {
let status = result.collection.getByIndex(0).get("AMDStatus").displayValue;
let program = result.collection.getByIndex(0).get("AMDProgram").displayValue;
if(status === "In Progress" && program === "ABC"){
resIdRows.push(item);
}
});
}
}
Please find attached screenshot below with an array of selected records vs another array of selected ABC records and string output as Selected order (empty string).