Say you have a repeating group filled with different fields, for example a list of employees and their first/last name. You don’t want to autobind the name fields, but you don’t want a save button in every cell either. How can you set up a save button to make changes to all the cells of a repeating group, using elements (in this case input fields) within that group?
It’s a workflow that’s surprisingly difficult to set up in Bubble. Sure, you can run an API workflow on a list of things, but it will disregard the info saved in the elements of each of the cells.
For the solution I came up with, I’ve used two of @gaurav’s plugins: Env Environmental Variables (bdk) and Utilities (bdk). You’ll probably be able to do this without the first one though.
How to do it
First, place an Environmental Variable element outside of the Repeating Group. This will serve as the trigger for the workflow you want to run in each cell. Set it up with a Yes/No type with the default set to No.
Then, set up a button that changes the value of the Environmental Variable you just created:
Inside each of the cells of the RG, you place an If-Then Workflow element.
What this does is trigger a specified workflow if certain conditions are made. Wait, you say: you can already do this with Do When Condition is True, and you’d be right - except, you cannot trigger a cell-specific action (an action that relies on elements within a cell) with a Do When […] workflow. But with the If-then Element, Bubble recognizes it as a part of the cell of the RG, and you can fetch info and manipulate elements within that cell.
In the If-Then WF element, set it up to react to the value of the Environmental Variable:
Make sure that Run automatically on change is checked.
Then, in the Workflow editor, set you the workflow to trigger when the IF condition is true:
If you choose Make changes to thing, you’ll see that you can reference the cell Data Type and elements within the cell where the If-Then WF element is located, allowing you to run a cell-specific workflow from outside of the RG.
Word of caution
Before you go overboard with this, remember that you are basically triggering potentially a shitload of workflows all at once, depending on the length of the RG. If you’re working with long lists, you can make your own app very sluggish or even timeout the operation if you demand too much of Bubble at once. Even if your list is not long now, consider the fact that it may be in the future.
Word of caution 2
Remember that you are not technically running a workflow on a list here: rather, you are triggering one single workflow inside each of the RG’s cells. If a cell is not visible (if you’re using pagination for example), it will not trigger. So as with all tools, it has it’s specific uses.
Hope this can be useful to someone, and as always, if you have a way this could be made even simpler, without plugins or if you happen to think my solution is an inefficient mess, let me know!