I need found a solution to Schedule API workflown on a list and that the processing occur in ordering way. The list should processing mandatory in certain ordering, but by my test I think this scheduling runs async every time, like a thread for each item of the list.
In my case I need iterate a json result for an external api. This list of thing I need orderi by a date attibutte and so process in ordering way, sync.
For most use cases you can trust it to execute in order with an interval of 1 second. If you’re calling an external API inside the scheduled workflow, though, then delays in that API could cause it to not execute in order.
I built an external API that returns a list of data that I need process in bubble. This process could be: create new data, change a data or delete a data. For choose what action I need to to, the order that I read the JSON returned of API is mandatory. For exemple, imagine the following json api return (is an exemple, is not my real return, is for illustrate):
Reading in order, at the final I have no data of “João Silva”, because the last action was delete.
When the order is not obey, tha last result could be “João da Silva” that is not the expected result
@georgecollier 's suggestion is good & simple to start – it might cover most of what you need. However if you want to be absolutely positive that it processes in order, use a recursive workflow.
I’m not sure if you’re able to handle a JSON natively in Bubble. You might need to
first iterate over the incoming list, save that into the Bubble db
after saving all (or some of the) items
start off another recursive workflow that takes that newly created list and iterate over that actually performing the action you need.
Save each object to iterate over as a text (:format as text) that is a JSON object. Provide this list of texts (list of JSON objects as serialised strings)
Within the recursive workflow, call your own backend using the current iteration’s JSON string to get it as useable JSON
I managed to implement the recursion, but the solution still doesn’t work, and all because the data source is an external API. I’ll try to bring more details.
My first step is to connect to an API through the API Connector. With the return from this API I create data in the DB.
The whole problem is in the asynchronous processing, because when calling the recursion the data has not yet been created in the database. This way I still have the same problem.
If I put the action in 2 buttons on the screen it would work, that is:
step 1: search data and save
step 2: process the data
But I need everything to be done only once.
Basicly, the step 5 occur before the step 3 is done and is incredible, but not works put a delay in schedule.
Sorry if I’m complicating something simple or if I’m not making myself clear.
I hope you can help me.