Getting bored with repeating the same tasks for different customers every day? Now you can automate them by using the ‘For each’ node in App Connect, which is available for both event-driven and API flows.
In the following example, we’re going to create an API flow that can update or create Salesforce accounts for all existing customers in NetSuite.
After the setup of an API flow, we can now add a node to retrieve up to 20 existing customers from NetSuite. (We could also configure the node to retrieve customers that meet specific conditions by using the button. But for this example, we want to retrieve any customers, so we don’t need to add any conditions.)
Then we’ll add a ‘For each’ node from the ‘Logic’ tab:
We set the collection of items to be processed by this ‘For each’ node to be the from the retrieve node that we have just created (you can type in JSONata expressions to generate your customized input collection for a ‘For each’ node).
To help us distinguish this node, we can edit the display name of it to be ‘For each: NetSuite ERP Customer’.
Also, we can choose which mode this ‘For each’ node should run in: either ‘sequentially’ or ‘in parallel’.
Note: If you choose to run a ‘For each’ node in parallel, you may want to check that the applications that are used in the ‘For each’ node can handle a large number of API calls in a short period.
In the branch of the ‘For each’ node, we then add other nodes to carry out the tasks for each customer. We will have access to the properties in a ‘customer’ object on the ‘For each’ branch to help us to configure the field mappings.
Finally, we can add another retrieve node to retrieve the contacts for each customer, and another ‘For each’ node to update or create the retrieved contacts in Salesforce:
Our flow is ready to go! When it gets invoked, the flow will first retrieve all customers from NetSuite. Then, for each customer, it will update or create an account in Salesforce, and retrieve contacts from NetSuite. Finally, for each contact, the flow will update or create a contact in Salesforce. We can now say goodbye to this repeated task!