Even though Bubble itself is mostly built on Javascript, there’s no way to run a script from a workflow action. Luckily, it’s easy to get around it by using the brilliant Toolbox plugin.
Install the plugin
The first thing we need to do is to locate the Toolbox plugin in the Bubble plugin store. This plugin has been around for years, and offers numerous extremely useful elements and actions.
Draw a button on the page
We’ll need something to trigger the Javascript action. For this we can use a simple button. Click on the button to see its properties, and then Click the Start/Edit workflow button in the element inspector.
Create the Run Javascript action
You’ll be taken into the Bubble workflow editor. Add an action in the button-click workflow, and search for Run Javascript or navigate to the Plugins submenu.
Enter the Javascript to run in the Action step
You can write or paste the Javascript directly into the action step itself, and it will trigger each time your button is clicked.
Javascript is a pretty easy programming language and can greatly extend Bubble’s features, like copying text to the clipboard. If you’re not fluent in computerese, make sure to visit the Bubble forum, where you’ll always find someone happy to help out.
3 Comments
Could you put some example js perhaps? I tried running a command to print to console and nothing happened.
console.log(“Hello World”)
Hey, thanks for the comment! In all honesty my knowledge on Javascript is very limited so I’m probably not the best person to answer this – I’d try posting this on the Bubble forum, and feel free to correct me if I’m misinforming in some way in my article!
i have a button inside repeating group and i am running javascript code in workflow using run javascript. but somehow it does not run first time i click …it runs on the every second click of a button inside repeating group? can u guide what is the problem there?