Use Collection parameter in script task

Hello community!

I need get in a bussines process a collection parameter and then use that in a script task into a foreach. Any example about that?




Like 0



Dear Federico,

Please check the instructions on how to work with collections within [Read data element]. This will help you to implement your own process.

Algorithm of the work with a collection from Read data:

1.Disable the formula validator in business process designer. You can open the console and execute the following script for that:

var featureCode = "UseProcessFormulaServerValidation";

require(["FeatureServiceRequest"], function() {

                var featureRequest = Ext.create("Terrasoft.FeatureServiceRequest", {code: featureCode});


                               forAllUsers: true,

                               state: Terrasoft.FeatureState.DISABLED // ENABLED

                }, ()=>console.log("Done"));



2. In [Read data] element go to extended options and tick:

Read first = true

Number of records to read = 100 //Number of records available in a collection.

3. Create a process parameter with EntityCollection type and map it to the resulting collection of [Read data]. This parameter does not exist out of the box, but you can create it manually. 


[#MyRead.Resulting collection#]

*  MyRead – [Read data] element header.

* Resulting Collection - added manually


4. Assign a process parameter to a new variable in ScriptTask. Here is the example how to process the collection:

EntityCollection entities = Get("MyEntity");

var result = new Collection();

foreach(Entity entity in entities) {

                var cityName = entity.GetTypedColumnValue("Id");

                string temp = cityName.ToString();




string displayValue = result.ConcatIfNotEmpty(",");

Set("MyResult", displayValue);

return true;


MyRead – reading datat in any element.

MyEntity process parameter with EntityCollection type. Parameter value= [#MyRead.Resulting collection#]

MyResult - string parameter. You can store record IDs from the collection. Then this parameter is shown on the auto generated page for the testing purposes.  

Best regards,


Lily Johnson,


I tried the above script task as below:

EntityCollection entities = Get("MyEntity");

var result = new Collection();

foreach(Entity entity in entities) {

                var productName = entity.GetTypedColumnValue("Name");

                string temp = productName.ToString();



string displayValue = result.ConcatIfNotEmpty(",");

Set("UsrLatestOrderProduct", displayValue);

return true;


But, here I'm getting below errors:


Lily Johnson,



Can you elaborate on how Auto-Generated Page works upon this case? 


Many Thanks

Riddhi Jadeja,

As we can see from the screenshots you have provided - GetTypedColumnValue is used incorrectly. 

GetTypedColumnValue("Name") is used without specified type of this field. 

It should be GetTypedColumnValue<string>("Name")

Kind regards,


Sarthak Jain,

Can you please specify your question with more details? 

How exactly Auto-Generated Page will be related to the discussed case? 

Thank you in advance,


Show all comments