Create a "list" of thing via API Workflow - Problem with second tasks

Hi !

I would like to create a “list” of new thing from a multidropdown.

For this, I followed this very good tutorial: https://www.youtube.com/watch?v=LLYaNHmt6_Y&list=PLvRZVR4itmEuaXL3VPh1-_nI_NbSpKeXD&index=25

However, after the first task of the Workflow API, I would like to add each created item in a field of another list.

This works but the list is never complete, one or more items are always missing.

I tried to add the task via a trigger event, and it’s the same thing, it works halfway, items are always missing.

‘I think’ the problem is that the first task of creating items is not completely finished when the second one starts. But I don’t know how to add a waiting time between 2 tasks … and I’m not even sure that’s the problem.

Thank you for your help !

1 Like

Dont’t work in backend

Yes, you’re right. You’re encountering race conditions. This is generally an issue with Lists on data types.

You can reduce the risk of this by assigning an interval between workflows. On your Schedule API workflow on a List (if using it), add an interval of 1 second or 2 seconds.

Now, if you have one trigger setting off multiple workflows all at the same time, there’s no easy solution (short of an overengineered queuing system). I’d just avoid using the list at all and instead jut Do a search when you need it rather than accessing the list directly.

Thank you but this action doesn’t exist on backend workflow …

I know … But in this situation, it’s the only way … :sweat_smile:

Thanks for these advices !! It seems to work ! :grinning:

the only way to reliably get this to work is to do a recursive workflow with a slight delay between the steps.

you still need a slight delay between the steps since if it is super fast to process bubble still drops records even though they get added sequentially.

I often do this like
schedule api workflow where
current number starts at 1
max number is 10 (number I want to create

create the thing
add to other thing
schedule same workflow again +1 to current number and 0.3 second delay (have condition to only run this after add to thing is not empty)
only schedule it if current is less than max number

you definitely want to do simple math here - plus 1 to the current number. DO NOT count created records as that is a search (heavier) and maybe the creation step fails and so you get an infinite loop…

backend api is best for this workflow since the front end could be interrupted and stopped before all X items are created and added to list (ie user navigates away from page)

1 Like

Thank you very much for all these explanations and advice

I had not seen that it was possible to add a delay! I did it and it seems to work well!

Another potential solution I recently used - when creating the list of things via API workflow, I included a field of type text. When triggering the workflow, I generated a random set of characters that I included for this field, and triggered another workflow that when the count of things with that random set of characters count = the number of things scheduled to be created, to add those items to the other thing. This prevented any potential race conditions, and added them all in 1 step once they were complete.

Very interesting process ! Thank you very much !!

1 Like