I know a lot of newbies asks that, I’ve red tons of topics before I’m writing my own.
Workflow for user is simple:
User clicks a button
X amount of records is created in DB and displayed to him
However the issue is on backend.
Create X records with attribute Y (so done by Recursive Schedule API Workflow)
Send it to external API (one of the parameters - list of unique ids searched by attribute Y)
The thing is - Step 2 is starting instantly and request is sent/received while Step 1 isn’t even close to finishing. I cannot relate to ‘Result of Step 1’ because it’s done as Scheduled Workflow API. I don’t even now the value (when I tried to debug - it was just a number as text). Tried to check if result is not empty - no luck, so I suppose it has some value as it’s starts, but not finishes.
Sometimes external request is called even before the first record appears (at least on a screen) - then it has some unique ids I cannot even find in correlated table. And this is intriguing as well.
I don’t want to schedule another workflow as it’s unpredictable. Records might be created nearly instantly or might take a minute to generate them all.
I also don’t want to split it into two different client workflow as user may close the page and then request won’t even trigger.
Tried to wrap workflow apis into custom event, but no luck. Maybe I did something wrong, because level of abstraction confused me (parameters of api connector call > parameters of workflow api call > parameters of custom event > another workflow api parameters to call the trigger)
Looks like you have most of the concept of looping in the backend. Consider these points:
each workflow step is run for each loop, unless it has “only when” condition to (for example) make it an “end loop only” step, or unless the workflow is terminated (I had reliability issues with terminate workflow)
each loop doesn’t “remember” anything from the previous loop, so any preserved state needs to be passed to the next loop, for example via parameters or saved in the database.