"only when" fails, but API is called nonetheless - intended behavior?

I’m reviving an old one, from 2017: Action Condition ("Only when ...") technically working, but not stopping "Get data from an external API" call from running

I assumed that this call

Should not be happening because the “only when…” fails (aka: evaluates to false), but it’s happening nonetheless (I can see it in the server). Is that the intended behavior?

If it’s Get data from API, then it runs as soon as it can to ensure it’s fast. The data is loaded, but the action is not executed.

If you want to control when an API data source is executed, it should be an action.

1 Like

Ok, fair enough. Just wish the interface would be more clear about this. Next best thing: @petter is this already in the manual? I searched and I couldn’t find it - maybe I was searching for the wrong thing.

The other one to watch out for is that in :format as text, data is fetched optimistically from both the yes/no branches (even though obviously only one can be true)

2 Likes

I guess this is not true if the group/RG is hidden on page load?

For elements, Bubble only fetches data when it needs it to evaluate an expression

1 Like

In Bubble, “Only when” gates the execution of the workflow action, not the data source evaluation. For “Get data from API,” the request fires immediately to optimize performance and caching, but downstream actions are skipped if the condition is false. To fully control execution, wrap the API call itself in a workflow action with the desired “Only when” condition.

1 Like

@rico.trevisan

Discussing this with the Bubble team, to be sure how the logic here works in different scenarios.

2 Likes

@rico.trevisan

Haven’t had the time to test this myself yet, but have you tried checking DevTools without using the debugger to see if the data is still downloaded? Looking at an expression with the debugger forces it to evaluate (so it can show you the result) even if it wouldn’t otherwise.

1 Like