Hello!

 

I have this array that gives me the prefixes of phone numbers. I need to use it in a Process in Script Task.

I don't really like that I have to add all the values in the array manually. Is there an option to get the values from a lookup and to add them in an array?

 

I would like to just create a lookup for all the prefixes instead of adding them one by one in the array.

 

Thank you!

Like 0

Like

1 comments

Hi,

 

In the business process you can read collection of records using examples provided here, add the result to some parameter and then process this parameter. Otherwise you can read values using standard "Read data" element in a cycle (which is not a good approach) and each read value can be also added to the array. 

Show all comments

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

 

Like 0

Like

1 comments

Hi,

 

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

 

selectedRows.forEach(fnProgramABCArray);

 

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

 

and 

 

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,

Oscar

Show all comments