AnsweredAssumed Answered

Loop through repeating array and map matching occurence

Question asked by dbarrow.ninety10 on May 22, 2018
Latest reply on May 25, 2018 by leif_jacobsen

I have a JSON response that includes two elements that correspond to ID fields in a repeating subdocument. Specifically, it stores the ID value of the default billing and default shipping addresses for a customer. The JSON profile looks like this:

 

My difficulty comes in figuring out how to loop through the 'addresses' array and find the instance with a matching ID field to each of the default address fields in the main object - default_billing and default_shipping in the image above.

 

I need to map the address data into Salesforce (Contact object, Mailing Address and Other Address). Because there can be a variable number of instances of the address array, I can't just add an identifier instance by occurrence.

 

My only thought is to create custom JavaScript, which the script itself is straightforward enough, but if I write a simple IF will that custom script run for every instance of the 'addresses' array?

 

Thanks!

Outcomes