Hi Team,



We are using an OOTB Webservice section to call the (GET) REST API endpoint and the response collection is captured in the "Response Parameter" of that web service. The response has a nested collection of data.

 

We are currently using the Script task to read the response data of a web service. Now it is required to get into the nested data set further and any insight on this would be helpful.



STEP 1: Web service Response

 

STEP 2: Script task to read web service response

var deliveries = Get<ICompositeObjectList<ICompositeObject>>("WebService1.Output_Out");
foreach(var delivery in deliveries){
//Delivery is again a nested data
//need to loop through the delivery (has parent record info and array of child record details)
}
 

Webservice Output:

{
   "output":[
      {
         "challan":[
            {
               "delivery_number":"DEL-251-253423",
               "delivery_id":1151109,
               "lines":[
                  {
                     "order_number":2011010049349,
                     "item_code":"RT3060-002GRL",
                     "grade":"A"
                  },
                  {
                     "order_number":2011010049359,
                     "item_code":"RT3062-002GRL",
                     "grade":"A"
                  }
               ]
            },
            {
               "delivery_number":"DEL-251-253430",
               "delivery_id":1151109,
               "lines":[
                  {
                     "order_number":2011010049369,
                     "item_code":"RT3060-002GRL",
                     "grade":"B"
                  },
                  {
                     "order_number":2011010049379,
                     "item_code":"RT3062-002GRL",
                     "grade":"B"
                  }
               ]
            }
         ]
      }
   ]
}



Need to traverse through the nested collection and one of the properties in the collection of values is array too {like section record information & Child record information} and then insert them into CRM table (Parent and child). Insight for processing this data set would be helpful.

 

 

 

Best Regards,

Bhoobalan Palanivelu.

Like 0

Like

3 comments
Best reply

Hello,

In order to process the collection inside a collection, you need to do the following:

1) In the process, create a new parameter and add values to it from the web server response:

 

 

2) In your script task, you need to proceed this parameter and get values from it.

Dmytro Vovchenko,



Thanks for the information shared.

We were able to achieve processing the multiple nested collection through the below script and insert the Parent/Child collection sequentially.

 

List&lt;object&gt; deliveryItem = new List&lt;object&gt;();
List&lt;object&gt; lineItem = new List&lt;object&gt;();
var serviceOut = Get&lt;ICompositeObjectList&lt;ICompositeObject&gt;&gt;("Output");
 
foreach(ICompositeObject chall in serviceOut){
	if(chall.TryGetValue&lt;ICompositeObjectList&lt;ICompositeObject&gt;&gt;("Challan" , out ICompositeObjectList&lt;ICompositeObject&gt; curChallan)){
		foreach(ICompositeObject _challan1 in curChallan){
				curChallan1.TryGetValue&lt;string&gt;("Driver_contact_no" , out string Driver_contact_no); 
				deliveryItem.Add(Driver_contact_no);
 
				if(_challan1.TryGetValue&lt;ICompositeObjectList&lt;ICompositeObject&gt;&gt;("Lines" , out ICompositeObjectList&lt;ICompositeObject&gt; curLines)){
					foreach(ICompositeObject _Lines1 in curLines){
							_Lines1.TryGetValue&lt;decimal&gt;("Secondary_quantity_ctn" , out decimal Secondary_quantity_ctn); 
							lineItem.Add(Secondary_quantity_ctn);
				}	
			}
		}
	}
}

 

Also, we can utilize this without performing the Step 1 of Creating Nested Parameter Collection in Parameters of Business Process. Since the Web-Service already has the response parameter of same. But the parameter name from Webservice is always with a suffix _OUT





Iteration of Composite object collection is done through by following the Type<> in below Interface

ICompositeObjectList<TObject>

Interface ICompositeObject


 

 

 



BR,

Bhoobalan Palanivelu.

Show all comments

Hello

I would like to build a business process parameter of type "Collection of records".

- The user is asked to choose an object in a lookup ( attachment file)

- This file is added to the collection (that is where I struggle)

- The user is asked if he want to add more object to the list.

- ... 

- The user validate and the list is used in a subprocess to process the choosen files

 

Many thanks if you can give me a hint on how to do that.   

Like 0

Like

3 comments

Dear Antoine, 

It's impossible to implement using basic application logic.

During single business process execution, it is possible only to upload files to a single object at once.

Hello, thank you for your answer.

I am not trying to upload multiple files.

I just want to ba able to add object references to an object collection parameter.

Let's say it like this:

- When you read Data from Creatio, if using filter others than ID, you get a collection of object. Which is stored into a "collection" variable.

-Now I have a collection, let say I read another object of the same type with anoter filter, I want to add that object to the above existing collection. How can I do that?

 

 

Thank you 

 

The code should look something like this:

// create collection/list or get from param
var list = new CompositeObjectList&lt;CompositeObject&gt;();
 
// create item and add to collection/list
var item = new CompositeObject();
item["SomeProperty"] = "Some value";
item["SomeOtherProperty"] = "Some value, etc";
list.Add(item);
 
// now set list in param
Set&lt;CompositeObjectList&lt;CompositeObject&gt;&gt;("MyCollectionParamName", list);

See https://customerfx.com/article/working-with-collection-parameters-in-a-…

Ryan 

Show all comments

Hi Team,

I can read the process parameter of Business Process in script task if it is string or number in an "Implicitly typed variable - var" as below.

 

1.var _recipientEmails = Get("RecipientEmails");

2.var _totalRecords = Get("TotalRecords");

 

 

how could we read collection of records parameter as in the screenshot?

var _collectionRecords = Get<?>("ContactRecordCollection");

 

 

 

Regards,

Bhoobalan P.

File attachments
Like 0

Like

4 comments

Hi Bhoobalan, 

 

You are welcome to check a suitable solution by the link below: 

 

https://community.creatio.com/questions/use-script-task-update-column-r…

 

Get<ICompositeObjectList<ICompositeObject>> parameter should work for a collection of objects.

 

Regards,

Anastasiia

Anastasiia Markina,



Thanks. 


 

Hi,

I'm need to find the smallest price of a list of products. 

I get the list using the Read data element with the read collection of records mode.

In the script task I want to loop through all products and save the price if smaller than minPrice.

I created a process parameter with a type of Collection of records called: ProductsList and the value is set to the read element I mentioned above.

I have issue working with the collection.

I get the collection with the following script:

var productsList = Get<ICompositeObjectList<ICompositeObject>>("ProductsList");

foreach (var product in productsList)

{

      int price = ??????

       if (price<min)

            {

               min = price;

             }

}

 

I don't know how to continue on the foreach, how to get the price of the product.

I tried product.GetTypedColumnValue<int>("price"); 

but it doesn't work.

Can you please help me with this?

 

Thanks, 

Chani

 

I tried the following and it worked.

         if (item.TryGetValue<int>("UsrIntProductAcademicYear", out int value))

         {

             if(value<min);

             min=value;

         }

 

 

Show all comments