Await Actions in Flows

Sometimes I really want to wait for something to finish before moving onto the next item in a flow. For instance, load a server connect to get a record and then open a modal to show that info. Right now I have to put in arbitrary wait times, or put the modal open on the success of the server connect which isn’t ideal IMHO.

Anyone else?

But actions based on events, such as calling SC, ‘Succes’ or ‘Done’, will not solve your problem?

Please show what you’re doing, because Teodor says it’s synchronous:

Perhaps you’re wanting to wait for Run steps to finish?

1 Like

I find page flows help.
Page flows expose the events on completion such as success etc
You can, as @vv-a2007 suggests, you can use events such as success to trigger the next event making them follow on from each other.

They do solve the problem, but then the action of what is happening is in multiple places making following what’s happening from start to finish more difficult to follow.

The flow steps are executed sequentially, i.e. synchronous. The only step that doesn’t run like that is the Run step, as it calls external actions.

So I guess that’s my request then, as in the initial explanation, can you make the run step requests execure sequentially? ie, server action runs and then modal opens?

Why not call the server action as a step in the flow instead of calling it from the page?
If you need to use run step, then you indeed need to use the dynamic events.

How do you do this?

I have a capacitor mobile app with sqlite. I use flows to sync back the data with the main app using server connects. It works but got messy though as I have to use on success and different flows. Think it ended up being broken down into about 20 steps. As I need the identity from the previous inserted record to add on the next record.

When I decided to return to development after a 20-year break and all my old experience was based on procedural programming, the concept of asynchrony in JavaScript also did not immediately become clear to me.
But in essence, it allows for a more flexible approach to the fact that any request to servers may not complete or end with errors; the user can also initiate different actions in a random order and will not be happy with unnecessary pauses and waiting.
So there are probably more advantages here, although we have to keep in mind a more complex tree of relationships than with a linear code

1 Like

Just to confirm - all steps in an app connect flow are executed sequentially and each is step is executed only when the previous step is fully done executing.

So if you have a server connect action step - the next step will be executed only when the server connect is fully loaded.

As Teodor explained earlier - all steps are fully sequential - except the “run” action - which goes its own way and the execution directly returns to go to the next step.

So you effectively you already have “await” on each step.

OMG - I’ve totally missed that you can run server connects from a flow directly. I’ve been using Run . :woman_facepalming:

Off to fix all my flows!

Thanks for the clarification.

2 Likes

It would still be good to be able to somehow wait for the Run/Run Javascript actions to finish before moving on to the next step. :grinning:

Well, if we call SC directly from Flow, how can we then access the results of its execution?

Server Connect action is available as a flow action step that you give a name and each sub-sequential step has access to its data under that name. You can choose it from the data picker.

So you can have like repeater as follow up step

Hey George, maybe it sounds obvious, but never used sc in a flow.
By loaded you mean done, like on success dynamic event that we wait for the result?
Or can we expext some timing issue?

Not got access to Wappler at the moment but from recall, flows attached to dynamic events do not expose results but if you use a page flow and run it from the event then page flows do.

Yes, and this stopped me from using SC in dynamic parameters. Now I tried to make it in Flows - but the situation is the opposite - it is impossible to set parameters for it from the page. Perhaps there is some other method?

When I refer to page flows i mean app connect page flows, not server connect

I thought it was called App Flows or is it somewhere else, can you show an example?