Is there a best practice way to execute actions or workflow steps on a list/array dataset?

This topic was automatically generated from Slack. You can find the original thread here.

Michiel Sikkes : Hey Ho. Is there a best practice way to execute actions or workflow steps on a list/array dataset? Eg: I want to pull a list of customers via polling and create or update a SalesForce contact for each of them. I tried thinking about emitting to another workflow via Pipedream SDK.

Dylan Sather (Pipedream) : for now, I will typically modify the code for the action to iterate on the data within the action itself:

for (const item of steps.step.items) {
  // original action code, modified to accept item
}

Would that work in your case?

We are thinking a lot about how flow control works and plan to introduce loop / conditional statements in the future, which will make this much easier.

Michiel Sikkes : Got it Dylan. That makes sense. I was hoping to use a standard action from the Salesforce API connection :wink: but copy-pasting the code from that is as good as any I guess!

Michiel Sikkes : Or fixing it by triggering a webhook event to another workflow from my original trigger. So that the workflow only receives a single object instead of a list.

Dylan Sather (Pipedream) : yes that’s also a fine solution. By the way, if it helps, you don’t have to copy / paste the code from the original action. If you expand the code section under the action, you can edit that action in any way you’d like. Since everything is just Node.js code behind the scenes, we like to give you the ability to fork that code directly from the workflow itself!

Michiel Sikkes : oh right, that’s a neat trick