I am trying to save data from an API call, it returns a collection of records. I wish to save these into a table. I do not know how to loop through this collection and save each as a record. Please advise.

Like 0

Like

1 comments
Best reply

Hi Pascal,

 

This can be achieved via OOTB no-code tools of Business Processes.

The response collection of an API can be sent to a sub-process with parameter filled and it can be set to run sequentially so that all the response data will be successfully inserted into the table.



Here is the article, https://customerfx.com/article/working-with-collections-from-a-web-service-element-in-a-process-in-creatio/

 



BR,

Bhoobalan Palanivelu.

Hi Pascal,

 

This can be achieved via OOTB no-code tools of Business Processes.

The response collection of an API can be sent to a sub-process with parameter filled and it can be set to run sequentially so that all the response data will be successfully inserted into the table.



Here is the article, https://customerfx.com/article/working-with-collections-from-a-web-service-element-in-a-process-in-creatio/

 



BR,

Bhoobalan Palanivelu.

Show all comments

Hi All,

Can some one suggest a better approach to loop through multiple records and modify them. Please note that the trigger is coming from Signal (Record Added).

 

Basically, I am trying to add multiple records using Multi-select lookup detail built using LookupMultiAddMixin.

Reference - https://academy.creatio.com/documents/technic-sdk/7-15/adding-multiple-records-detail?_ga=2.11560502.366292848.1628844467-134737415.1626226816 

This is configured in a custom detail and on add, business process places that many number of rows to that detail. Now based on the detail object specific column value, I want to update all the contact records that is mapped with that detail.

 

But what I notice is it is updating only 1 record. Kindly suggest how this could be achieved.

 

Like 0

Like

2 comments

Hi Anupama, 





 

One of the ways to create a loop in your process to work with the collection of records is  to create a sub-process and pass the collection into the subprocess. 

You can refer to the example below and create the process you need: 

 

 

Signal "Contact Added" element: 

Read Data "Read Contact" element:

 

 

For the sub-process, you would need to specify the [Parameters] of it:

 

 

And make a filter of the element within the sub-process based on the ID:

And finally, you would need to specify this parameter in the parent Business Process:

 

 

You may also find these academy Articles useful:

 

https://academy.creatio.com/docs/user/bpm_tools/process_elements_refere…

 

https://academy.creatio.com/docs/user/bpm_tools/bpm_process_examples/us…

 

Hope this helps!

 

Thank you!

 

Regards,

Yurii

Danyil 

Thanks Yurii Sokil for the detailed instruction and the sequential  Execution Mode is something I haven't tried it before. Would definitely try that.

 

In between I tried another approach where-in at the entry point where the Signal action is placed, I unchecked the option of "Run following elements in the background". With this, until the process is completed, I was able to read the required values and add/edit/delete multiple records.

 

 

Show all comments

I have been struggling very much with handling collection type response parameters in web services.

When response parameters are or normal type they are very easy to handle in the business processes. Here we are able to handle them as parameters on the Call web service process element. And use these in the process right away.

When there is a Collection which is returned, this is very different. Now the Call web service element parameter is of type Collection of Objects with attributes.

It seems to me that this parameter-type is very difficult to handle in the business process. I can't seem to find documentation in the Academy about how to extract and loop through the contents of the Collection of Objects with attributes.

What I have found in the academy is this article about setting up the Web service.

https://academy.bpmonline.com/documents/administration/7-14/adding-resp…

What I need to learn is how to handle them in bpm'online business processes.

Is there something about this in the Academy?

Is writing source code the only option? It's difficult to debug.

Like 0

Like

6 comments

Dear Julius,

Unfortunately, it is impossible to handle parameters that have the “collection of object” type without using the source code.

Therefore, in this case we recommend using “ScriptTask” element for both calling the web-service and processing the results of call.

For more detailed assistance, please contact technical support.

Best regards,

Norton

Norton Lingard, Thank you. Is there anything like this in the academy? Because there is a special bpm'online syntax to go by in the source-code.

Dear Julius,



The service call in a "Script task” business process element can be implemented via native C#. Please find a lot of examples on how to do that in Google. For example, several links below:



https://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c



https://code-maze.com/different-ways-consume-restful-api-csharp/

Please note that it is possible to use the native C# collections instead of working with the the special bpmonline collections.

Best regards,

Norton

Hi Julius,

 

Did you manage to solve this?

 

I'm struggling with the same issue and didn't manage to get it to work.

 

Looking forward to having Your answer.

 

Raz

Norton Lingard,

Hi Norton,

 

Is there another example on how to do it in the script task?

 

I tried implementing it based on the links you posted and I'm getting many error messages when posting the code.

 

Thanks,

Raz

Dear Raz,

 

Please find another example in the article by the link below:

 

https://stackoverflow.com/questions/3900371/how-can-i-call-a-webservice-from-c-sharp-with-http-post

 

If you still can’t resolve the issue please provide us with a source code that you wrote and errors that you got.

 

Best regards,

Norton

Show all comments

Hello Community!



I confronted with the problem of creating a сycle passing through the records of the detail.

The Account page has a detail Address. How can I pass through the detail's Address records in the business process to change the value of the field in this detail?

Can anyone help on this issue.

Best regards,

Mariia

Like 0

Like

1 comments

Dear Mariia,

To add a record to account address for specific account you can use a business process with a parameter like on the screenshot http://prntscr.com/me25i0. This process will add one record to account address detail for "Test" account. To edit existing records in this detail you can build a business process like on the screenshot http://prntscr.com/me25ys. This process will change ZIP code for an account "Test" and it will be done for the record which have ZIP code set for 322. You can also add parameters to your business process and use them when triggering a process. You can also bind a business process to a page so to be able to trigger this process for a particular account record. Please read more about binding business process to a page here.

Best regards,

Oscar

Show all comments