I need run ordered Schedule API workflown on a list

Hi,

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.

Is there any way to execute a list in Sync way?

Well, technically yes. In this case you would have to use a recursive workflow instead of a schedule workflow on a list.

Thanks for tour reply Marcelo.

And how is It works? I really don’t know.

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.

1 Like

Can you give us more details of what you are exactly trying to do? Be more especific about the order and datas you want to iterate over.

My problem is:

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):

[
{
“id”: 1,
“name”: “João Silva”,
“action”: “create”
},
{
“id”: 2,
“name”: “João Silva”,
“newName”: “João da Silva”,
“action”: “change”
},
{
“id”: 3,
“name”: “João Silva”,
“action”: “delete”
}
]

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

FYI: Recursive API workflows | Bubble Docs

@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

  1. first iterate over the incoming list, save that into the Bubble db
  2. after saving all (or some of the) items
  3. start off another recursive workflow that takes that newly created list and iterate over that actually performing the action you need.

I’m a fan of, in this scenario:

  1. 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)
  2. Within the recursive workflow, call your own backend using the current iteration’s JSON string to get it as useable JSON
  3. Do what you want in the workflow
  4. Schedule next iteration
1 Like

Hello Guys,

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.

image

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.