Skip to main content

HI All,

 

i have an object store variable(key as Id, value as Boolean). Now i want to iterate the store variable and prepare Json array out of it. Please guide me.

 

My end goal is to hit the salesforce with this json array(single DML for bulk records instead record by record)

1 answer
  1. Jan 29, 2024, 1:02 PM

    To achieve your goal of iterating over an Object Store variable in MuleSoft and preparing a JSON array from it, you will typically follow these steps:

     

    First, you need to retrieve the contents of your Object Store. Depending on how your Mule application is set up, this might involve using the Object Store connector or accessing the Object Store programmatically.

     

    Once you have the contents of the Object Store, you can iterate over them. In DataWeave, you can use the

    map function to iterate over each key-value pair in your data.

     

    As you iterate over each item, you'll transform each key-value pair into a JSON object and then collect these objects into an array.

     

    Finally, you'll use this JSON array to make a bulk API call to Salesforce. Make sure that the JSON structure you create matches what the Salesforce API expects for bulk operations.

0/9000