Looping and API Calls

Is there a way to run a nested for loop in workflows?

For example, some of my results that I am looping over have nested data. I am currently using {{value.results['0']. id}} essentially hard coded. This works great if there is only ['0']

How can I run the API call for all the .results['0']

Just doing some psuedo code

For each value in code1
     For each result in results
              Run API Call for result

Hi Daren,

One way to do nested loops currently is to create a workflow that contains the second loop and call it from the parent workflow:

The child workflow would have to have a response block for the parent to wait for it to finish and get its results.

Let me know if this solution works for you.

Hmmm - I think what you are saying makes sense. I'll give it a go and get back to you. Thanks!

Is there another way to do this? I did get your method to work, and I appreciate your help! However, I discovered I needed another layer of looping which would require a third sub-workflow. I created a feature request for adding nested looping for anyone who stumbles upon this looking for something similar:

Thank you for the feedback, and I agree this is not easy to set up. We are planning on making this experience better with support for multi-step loops, and will keep in mind this nested loops use case!

Unfortunately, there is no other way currently with loop blocks. The other way to set up this nested loop would be to use a code block and write custom looping logic.

OK - thank you! Quick follow up about the code implementation - would I have to code the entire API request or can I trigger an API Call Block from the Code Block?

You can trigger an API call from a code block by creating a function. For example: