Update collection based on value from other collection


If you please let me know the resolution of the issue I am facing.

I have a collection (say Col 1)which contains Account Id, payment status, and other fields.A web service returns payment status value based on the Account Id.After getting the response from web service I am keeping the response in a separate collection(say Col 2) which contains two fields Account Id and payment status. I want to update the records of Col 1 from Col 2 based on Account Id. Process entity has 1 to n relationship with both the collection I found Xpath expression to add and delete a record from a collection but did not found anything to overcome this situation.

Comments (1)


Dear Atmaram

You will need to iterate over the two collections and compare their accountIds. If the accountId matches, you can update the payment status in one collection from another.

Here is a sample script that you can refer to. Ofcourse you will need to modify it to match your entity and attribute names

Hope this helps!

var Collection1 = CHelper.GetValueAsCollection(<ProcessEntity.Collection1>);

var Collection2 = CHelper.GetValueAsCollection(<ProcessEntity. Collection2>);

for (var j=0; j< Collection1.size(); j++){

var col1AccountId = Collection1.get(j).getXPath("Accountid");

for (var i=0; i< Collection2.size(); i++){

var col2AccountId = Collection2.get(i).getXPath("Accountid");

if(col1AccountId == col2AccountId){

//update the payment status in collection 1 from collection 2 of the corresponding object

Collection1.get(j).setXPath("Paymentstatus", Collection2.get(i).getXPath("Paymentstatus") );