Unable to push values into array correctly.

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);


                    Type: "Terrasoft.MenuSeparator",

                    Caption: ""



                    "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!");



                    var selectedRows = this.get("SelectedRows");

                    console.log("Selected records : ", selectedRows);

                    var recordsnumber = selectedRows.length;

                    var resIdRows=[];

                    var resIdForArray="";


                    console.log("Selected ABC records : ", resIdRows);

                    var selectedOrder = resIdRows.toString();

                    console.log("selectedOrder: ", selectedOrder);

                    var args = {

                        sysProcessName: "AMDProcess_BatchAssignments",

                        parameters: {

                            SelectedRowsCol: selectedOrder,

                            NoOfRes: recordsnumber





                function fnProgramABCArray(item){

                    var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "AMDTestPlans" });




                        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"){







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).


Like 0





The issue here is that ESQ is asynchronous and as a result once the:




is called, the browser continues executing the main runCustomProcess, but in addition executes the fnProgramABCArray in the background and when the


console.log("Selected ABC records : ", resIdRows);




console.log("selectedOrder: ", selectedOrder);


are executed they won't show anything, these will be an empty array and an empty string.


You need to modify this logic and perform the filtration of records in the business process directly where you can check all the records passed using either the read data element and the conditional flow or a script task that uses the SelectQuery class to check data consistency.


Best regards,


Show all comments