How to wait for SQL to complete

In a single workflow I make an SQL call to count the number of records in a MS SQL table which works fine. The issue is that the workflow doesn’t seems to wait for the SQL response before jumping to the next action.

Ex.: If the 1st action of my workflow is to set a custom state with the result of the SQL request, and the 2nd action evaluates the custom state’s value, it will just be empty.

Is there a way to make the workflow somehow wait for the response to arrive?

shout out to you @mishav , you’ve been present in many posts using SQL Connector!

Try, right after the SQL call workflow action, triggering a custom workflow that in its actions evaluates the custom state. That’s how we solve asynchronous stuff in Bubble, including when making plugins… firing an event (so, another workflow) solves any async code issue one may have, because I found out that Bubble sometimes does everything synchronous and then everything asynchronous on that workflow.

However this is weird because usually when doing data calls from the API connector I get consistent results, not needing the method above. But when I don’t, that’s what I resort to.

Does bubble handle SQL calls with the same voodoo as “internal” data, or is it more like an API?

https://manual.bubble.is/building-plugins/loading-data.html#loading-data---asynchronous-versus-synchronous-code

As far as know from my own testing and reports from others, with the same voodoo that made me (and admittedly others) pull a bit of hair when first dealing with it. It’s simple once we understand, though.

Bubble is a wormhole. Possibly use node somehow? Or make the conditional you suggest on a synchronous node “timer”? Seems like that might make the solution more complicated than the original problem though.

You’re right. On my problematic workflow, I call several SQL request and try to evaluate them by firing en event from a plugin I made. The thing is that instead of running the events when they’re called, they are queued after the completion of the first workflow.

It will make things a little more complicated for me, but instead of firing events, I’ll call custom workflows which will execute at the right time.

Thanks for your help!

Yeah! That’s how it goes. Events are queued after the current workflow, triggered custom workflows are inserted in the middle of the current workflow.