Run two recursive workflows with one trigger

I have recursive workflows A and B.
A creates about 50 to 100 data records, and B makes changes to about 1 to 30 of the created records.
This works fine if I create and run separate triggers for each.
However, if I call A in step1 and B in step2 within one workflow, it will not work.
Specifically, changes in B are not reflected well (workflow processing is completed)
Even if I take a gap between B’s schedule start and current date +5min, it doesn’t work.

Does anyone have any solution?

Hey!

You’ve probably a race condition going on where the order of the updates is not quite how you expect it.

(Or, as outside thought, it might be a bubble limitation in there with chaining workflows together, which I have seen in some circs).

Without seeing the code, it is hard to tell, but I have a feeling about what might be going wrong…

I think you will need to save the changes you are making memory (custom state) and then use that list to make the second set of changes.

Or alternatively do this using some flags in the database to make items for further update (a bit hacky).

One way or another you need to the Unique IDs of the list you are changing in the first workflow, available for those that need changing in teh seocnd work flow.

If you see what I mean?

Does that mean saving the list created in A in the front-end custom state and referencing it in B?

But I don’t think you can save it because the front-end custom state value cannot be referenced in the back-end workflow

Am I understanding it wrong?

You can save information in the custom state and then pass it through from the (front end) workflow to the backend workflow upon initialisation.

Sorry, how do I do that?

As I understand it…

Trigger event (front end):

Step 1: Execute schedule API “A”

A> Recursive workflow that creates dozens of data records (repeats N items)

Save the list of records created here in the custom state (how? Is it in the workflow of A or in step 2 of the trigger event? Either way, the values ​​cannot be referenced)

Step 2: Execute schedule API “B”

B> Recursive workflow that references the list saved in the custom state and changes all of these values ​​(repeats N items)

It is quite hard to be specific without seeing the exact workflow. A screen shot would be useful.

But broadly speaking, there will be a trigger when you start the process. Like say a button, or an event which will trigger a normal Workflow.

At that point you can store the list if items in a Custom State as a list, and then pass that to the back end workflow (I am assuming you mean an API Backend Workflow) to loop through the changes you want to make.

Yes, that’s true.
But first I need a way to pass the list I created in the recursive workflow to the front (custom state).
Is this possible?

Again I am just guessing, but go and get the list of rows created in Workflow A, by using Do Search to retrieve them, and then push them into Workflow B.

That’s not using custom state, is it?
And currently I’m building it that way and it’s failing…

Consider using a Database Trigger event for B.

1 Like

Sorry, my explanation was not perfect.

The repeat workflow B adds rankings to multiple data created in A.

In other words, B needs to start after all workflows A have finished.

Wouldn’t a database trigger mean that B would be scheduled every time data is created in A?

A database trigger is a good idea. the other way is to mark data as you go for later change and then run the second query based on the results of the first.

Would you like to share screenshots so we can see what is going on. It helps for context, otherwise this is all very abstract, and we can only make suggestions based upon guesses.

Thank you
I’ll share some screenshots


The first one is the trigger workflow
It calls schedule APIs A and B

The second one is the recursive workflow for schedule A
It creates a new data record from the key (list) specified in the trigger event

The third one is the recursive workflow for schedule B
It passes the data created in A in a list in order of points and adds the ranking from the top

OK this is useful.

If I have understood this correctly…

I wondering whether it would be better to use the results of WF A and pass those in to WF B - e.g. using Result of Step 1.

I think the key issue where is the order of events. It may be that WF B is executing before WF A completes.

But if you refer to the dataset in WF A (step 1) by passing them in to WF B as Result of Step 1, you may have more success.

Some background here: How to Use the "Result of..." Expression | Bubble

I hope that helps…

Yes, I thought of that idea too. But it doesn’t work.

Because what is executed in step 1 is a call to the schedule API, and what actually creates the data record is the backend workflow.

The result of the backend workflow cannot be referenced in step 2 (calling B) of the front trigger.

Also, as I learned in my previous post, it is difficult to send the data list created in the backend workflow to the front side…

Ok sure.

Is there a scenario where both WF A and WF B are both in the Back Workflow - so you can then pipe one in to the other?

Yes, that’s what I was trying to do at first.

I called Workflow B in the final step of Workflow A, but that didn’t work either.

This is probably because Workflow A is a recursive workflow, and the call B event in it gets executed multiple times.

Hmm, is there any way around this?

Yeah. It is tricky.

You can have a two recursive WFs in the same backend WF. Perhaps you can reorganise and branch the backend WF. Then you can pass the results of one in to the other?

This topic was automatically closed after 70 days. New replies are no longer allowed.