Working With Collection Parameters in a Process in Creatio

For parameters in processes, you can easily set and get values in code ScriptTasks for simple parameter types. However, it might not be as obvious how to work with a collection parameter. For simple parameter types, such as text, you can get and set values using the following:

// get text parameter value
var val = Get<string>("MyParam");

// set text parameter value
Set("MyParam", "Some new value");

This article will outline how to get and set a collection parameter. This is often useful to do things such as populate a collection that you’ll send to a sub-process or Web Service, or to just keep track of a list of items to reuse later in the process.

For this article, we will create a collection parameter (type: Collection of Records) that will look like the following:

I’ve added two parameters, or properties, to the collection: “Name” (text), and “SomeDate” (a datetime). Now, in a script task, we’ll populate this parameter with a new collection and add two items to it. The code will look like this:

// create new collection 
var list = new CompositeObjectList<CompositeObject>();
// create item and add to collection/list
var item1 = new CompositeObject();
item1["Name"] = "Some value 1";
item1["SomeDate"] = DateTime.Now;

// create another item and add to collection/list
var item2 = new CompositeObject();
item2["Name"] = "Other value 2";
item2["SomeDate"] = DateTime.Now;
// now set list in param
Set<CompositeObjectList<CompositeObject>>("CollectionParam", list);

In the code above, we are creating a new collection, a CompositeObjectList that will store CompositeObjects. Note, on the first line, we’re just creating a new collection to populate, however, we could have also just retrieved the empty collection from the parameter as well, like this:

// get the collection parameter value
var list = Get<CompositeObjectList<CompositeObject>>("CollectionParam");

// now add items to it as we did before

Later if we want to read that collection and iterate through the objects we added to it, we could do the following (in this sample, we’re looping through the objects in the collection and just building a long string of the results):

// get collection from param
var list = Get<CompositeObjectList<CompositeObject>>("CollectionParam");
var text = "";

// now loop through the objects
foreach (ICompositeObject item in list)
	// "Name" is a property in my collection param 
	if (item.TryGetValue<string>("Name", out string value)) 
		text += value;

	// "SomeDate" is a property in my collection param 
	if (item.TryGetValue<DateTime>("SomeDate", out DateTime dateValue)) 
		text += " - " + dateValue.ToString();

	text += ", ";

Set("TextVal", text);

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!