JavascripttoBubble value empty on first trigger but correct on second click

I’m running into a strange issue with the Toolbox plugin’s JavascripttoBubble element when returning results from custom JavaScript.

Setup:

  • I have an input field for IBAN.

  • A button runs a Run Javascript action (Toolbox).

  • The JS function validates the IBAN and calls bubble_fn_iban("yes" or "no").

  • The JavascripttoBubble element (iban) is set to Value type = Yes/No and Publish value = checked.

Expected behavior:
When the button is clicked, the JavascripttoBubble value should immediately update to “yes” or “no”.

Actual behaviour (Bug):

  • On the first button click, the JavascripttoBubble’s value is empty.

  • On the second click with the same IBAN value, the value shows correctly as “yes” or “no”.

  • Console logs confirm that the JavaScript function is returning the correct result even on the first click, so the issue is not with the function itself but with the way Bubble/Toolbox publishes the value back into JavascripttoBubble.

Any help or guidance would be deeply appreciated.

Without seeing what you’ve set up, it’s a bit tricky to help… But my guess is that the “Run JavaScript” action in Bubble might be running asynchronously, not following the exact sequence of your workflow, which could explain why you’re getting an empty return.

In the action settings window, there’s actually an option to run it synchronously with your workflow — that might fix the issue.

If not, it’d be helpful if you could share some screenshots of your workflow, the actions, and their configurations.

FYI this needs to be valid javascript, i.e. pass a boolean true or false, or be evaluated as boolean. I assume this is already working …

The value is empty at the time of the start of the button workflow, and at later steps Bubble won’t bother to retrieve the updated value, due to internal workflow optimisation logic.

The way to use the updated value is to do so in another workflow, started by either the javascripttobubble event, or by trigger a custom event.

Have a look at these FAQs and linked examples: FAQ - Toolbox docs , FAQ - Toolbox docs