Application Level (Globally) accessible Custom Events

I am starting to notice that I could really do will globally accessible custom events in workflow, i.e. a set of events that can be accessed from any page’s workflow.

I am finding I am now repeating workflows because common functionality can be triggered from multiple locations/pages, e.g. Notifications etc.

I am thinking that in the Assign Folder, you could select a Global folder which can be seen anywhere in the app, and then in the trigger custom event you could ‘see’ those global events.

Also, on a similar theme, application level triggers would be good. e.g. Data event for the tables. Do When row added/deleted etc.

1 Like

The way users do this right now is by having one reusable element with workflows only and add this element, hidden, on the pages you need it.

4 Likes

Thanks…

I support @DaveA. This is a great idea I though about too :

  • Workflows at page’s level. Ex : Display data + show popup & basic elements modifications
  • Global workflows for core process. Ex : instanciate an object, accept / cancel an order, sign in a new user…

Then the way we design our apps may be better as soon as we start. Global workflow use would be closer to an inner API.

I just tried to do this, still doesn’t let me do what I want.

For example, I created a CustomCreateNotification event, it receives a CustomerOffer thing when an action is performed on the page, the workflow then creates a notification based on the content of the customer offer, and routes the notification also based on the content of the CustomerOffer.

Using the approach you suggest, if I put all this into a reusable element, and then place the re-usable element onto the page, I cannot trigger the custom event and pass in the CustomerOffer thing.

The only way I can see to do this using a reusable element, is to add more logic to process custom states, use customstate change triggers in the reusable element and set state workflows in the page, etc. adding complexity.

Unless I’m missing something here…
:confused:

If the CustomEvent was available globally, it would be a simple case of TriggerCustomEvent and pass in the CustomerThing and everything would be hunky-dory…

Why cannot you trigger the custom event? Did you use the action “Trigger a custom event from a reusable element”?

3 Likes

I didn’t see that as an option in the menu…hmm, i’ve gone and deleted the RE now, I’ll need to recreate it again and see what is going on…

Ok…All good! See it now…either a senior moment or a hiccup!

Maybe things where a bit out of whack with Slow Response from Bubble as it has been a bit hit and miss for a while when I was trying this first time. Had several “saving” timeouts and lost changes.

Can I just ask some follow-up questions to clarify…

So to create “global” app workflows, today you need to create a hidden reusable element and trigger a custom event on that element on every page you want the workflow to run?

I have a function that should change an [active] state to [not active] when an (argument [time] < current time) (the state is used on other pages for displaying products or not). SO, whenever/at all times, “a certain data field < current time”, the change should occur. As I understand the “do when”, it only applies when the particular page is loaded. Will that function trigger automatically as long as page is active?

If yes, what’s the difference between the reusable element method and copying/pasting the workflow on each page you need it?

Other comments to achieve above?

Purely ease of maintenance; when making changes to the workflow, not having to update and test every page with the same change.

2 Likes

yes ok. No functional difference. Thanks.

I’d sign a +1 for “global functions”.

I’d like to highlight this point. What’s most important is that it reduces the code size and limits the number of possible areas where you have to look when debugging. If you had copied and pasted a workflow on multiple pages, and had to make a change, you will have to maintain that change across multiple pages. Unless you document your work extensively, you will eventually forget to update a single workflow. Always reuse work whenever possible. You’ll thank yourself later.

1 Like