Triggering multiple js2bubble events from javascript

Hi all,

I’ve been trying to get the following working for a while but couldn’t figure out the way to do it and didn’t find any help in the forum.

I’ve got a JSON object (using the JSON Machine plugin) that stores some data. In a workflow I’m listening for change events, and when this happens I have a Run Javascript element that calls 2 different JavaScript to Bubble functions (see picture below).

The elements that you can see on the left are Javascript to Bubble event for the 2 calls I’ve mentioned, and in each of this calls the first thing I have is a Run JavaScriptinstance to print a message, but only one is printed.
Captura de pantalla 2024-08-05 a las 20.00.37
Captura de pantalla 2024-08-05 a las 20.00.45

Is it possible to call multiple JS to Bubble functions? If so, what am I doing wrong?

Thank you in advance!

Hi! Yes, it’s very much possible to do that. Can you show the editor of your 2 JS2B elements? Generally when I’m copying them, I forget to change the function name which is why it doesn’t work for me sometimes haha but we can take a look

Hi! Thanks for the quick response! Here are the screenshots, names are different so I wouldn’t expect any clashes.

You should check the Publish value checkbox in the second JS2B element

1 Like

I would add that if your changing the names and IDs of the same object, you only need one JS2Bubble function. Just pass two values…

Thank you guys! I really missed that one. I didn’t expect the checkboxes to be unchecked since I had copy pasted the first bubble element and I had them checked. Anyway, thanks again!

No worries :slight_smile:
Also check out Javascript to Bubble - Toolbox docs to return multiple outputs using the same JS2B element (I agree with what @ken1 has suggested - it’ll be cleaner and easier to maintain)

@ken1 @Zeroic Thanks for the suggestion, I’ve migrated to using a single js2bubble element. Much nicer and cleaner! :+1:

1 Like