Reusable Actions in Workflow

I really like how easy it is to copy/paste actions, but I think one way to make it better would is by have a way to mark certain actions as reusable and have them show up in some type of dialog/popup so you could easily search and pick them across events and workflow.

2 Likes

That’s what custom events are for. Explore :slight_smile:

1 Like

But an event is attached to a specific element (e.g. button 1), correct? I want to be able to be on a different workflow and attach a previously created action on a different element (e.g. button 2).

Also I haven’t figured out how to save an event as a custom event. My custom event popup is empty.

"Create a custom event…

Bubble lets you create some custom workflows, so that you can reuse the same logic in more than one workflow. This event lets you define such a workflow. You give a name to the workflow, then you’ll be able to use a ‘Trigger a custom event’ action to run this workflow from another workflow. You can think about this feature as ‘functions’ in Bubble.

Event name

Type here how to name the workflow. You’ll be able to select your custom workflows in the ‘Trigger a custom event’ action by its name.

Type of workflow thing

If you want the custom workflow to be able to take a thing (entry from the database) as an argument, define the type of this thing here. If this field is set, the ‘Trigger a custom event’ action will prompt you to define which thing should be sent when running this workflow.
"

1 Like

Not exactly straight-forward to define such events at some page when they’re reusable - can they talk to that page from another page? if not they should either be shown at different section in the workflows (say the bottom half part hold those reusable events and the top hold the page specific ones), or as I had suggested at other post make a page that’s called “Application” to hold events (and maybe UI parts that show up in all pages, like say a common header [like a template that is])

How do I name a workflow?

Now that I got how the work, found a use for the custom events. In the workflow shown in the screenshot, at change of each StarRating element’s value I want to calculate the average score and put in the DB for later reuse (since it’s hard to calculate complex formulas with no parentheses I can calculate their parts gradually and keep them)

From description in reference I thought you could reuse them at other pages, but I guess they’re per-page only (can call those functions from other events. As I wrote above, it would be nice to have an Application page too to host Data-related workflows (do stuff when data changes) where you could probably also define global functions visible by all pages (since those will be able to access only data and global UI defined at that page [that UI would be like a template, repeated at each page, so flows that use those names would work everywhere])

2 Likes

To give a name to that custom event I did this:

2 Likes

I really don’t understand what’s the difference between “trigger a custom event” and “trigger a custom event when data changes” since they both take no parameter. Plus this is an action, what does it mean “when data changes”? Does it pause and wait for something? Or does it skip execution if no data changed? What data?

btw the “trigger a custom event from a reusable element” mean you CAN have global functions (custom events) and reuse them at any page, you need to place the reusable element in the page though, since that custom event may be doing stuff with the controls in the reusable element too (wouldn’t want its actions to break)

1 Like

It allows you to do something when a “watched” data item has changed. So maybe a message has been received, or a bid placed etc etc

So the data changing in one users screens (clicking bid) causes an action in another user’s screen (“Bid received pop up”).

So in effect a listener.

2 Likes

Found where to go to create custom events. It’s only under the “Click here to add an event” on the Workflow page

3 Likes

where do you select the watched item?

Create the Custom Workflow.

Then under the action, you have …

You select the “thing” to watch, and the field on that thing, in the parameters.

1 Like

when the event has no param and I add this action it has no option on what field to watch for. Thus user doesn’t understand how it works differently. Also not sure what it does even when I have a param at the event. Does it freeze at that point of execution till some data changes?

aha, shown as an issue if you haven’t selected an event that has param, hadn’t noticed. If that action with the issue had a red box I would have noticed

1 Like

Make sure you trigger the “listener” workflow on something.

And that the data is set AFTER the listener is triggered.

So you can’t set it on page load and then set the workflow thing it is watching. You need to have the thing, and then trigger the wait.

1 Like

could you provide a sample case scenario and screenshot?

Will look at doing it at some point.