Trigger Event
Trigger event
Also known as a "database trigger event", this event is defined in the Backend Workflow section and runs workflows triggered by changes in the database. Whenever an item of the given type is modified, we check the "Only when..." condition of the event, and if the condition passes, we run the workflow. This is useful for situations where a given piece of data could be modified by many different places in your application, and you want to make sure something happens each time the data is modified in a specific way. For instance, you could use this to sync the value of certain data types to an external API whenever the data is modified. Trigger events are kicked off by any change to the data, regardless if the change is initiated by a workflow, an API call, or from manually editing the data in the editor.
Thing before change and thing now
When working with database trigger events, there are two special data types:
Thing Before Change"
Thing Now
"Thing" will change to match the type of thing you are working with).
Thing Before Change
Represents the data of the thing that was changed prior to the changes being made. For example, if a User has their first name changed from John to Jane, the Thing before change data source will return John.
Thing now
This represents the current data (i.e. the data after the change is made). For example, if a User has their first name changed from John to Jane, the Thing now data source will return Jane.
If a thing is created or deleted
Triggers are also fired when a thing is created or deleted.
Created
If a thing is created, its thing before change data source will return nothing, since there is no former thing to refer to.
Deleted
If a thing is deleted, its thing after change data source will return nothing, since the change made to the thing was to remove it altogheter.
Precautions
There are a few caveats and precatutions you should be aware of when using trigger events.
Multiple changes in one workflow
If a workflow modifies a thing multiple times, we only fire triggers once: "Thing Before Change" will be the data at the beginning of the workflow, and "New Thing" will be the data at the end.
Privacy rules
First, although you can use "Current User" to see which user, if any, initiated the workflow that changed the thing, trigger workflows run with full administrative privileges and privacy roles are not applied while the trigger is running, so any searches performed during the workflow will return all results, not just the results the current user is allowed to see.
Triggers cannot kick of other triggers
Triggers cannot kick off other triggers: if data is modified by a workflow initiated by a trigger, we do not check to see if those modifications are eligible for initiating other trigger events.
Data source availability
The "Only when..." condition can only use "Thing Now" and "Thing Before Change" instead of the full list of Bubble data sources. The full list of data sources are available in the actions kicked off by the trigger.
A note on workload: keep in mind that workflows kicked off by triggers consume server capacity, like any other Bubble workflow. If your application kicks off multiple trigger workflows every time data is modified, this can add up to a lot of overhead to the total capacity used by your application.
To control this, use strict "Only when..." conditions to make sure you are only running trigger workflows when you need to. User manual article series: Pricing and workload
Note: If you have more than 20 database triggers that kick off at once, the remaining triggers will be scheduled to protect your app's infrastructure from consuming too much memory.
Event name
Enter the name of the workflow.
Type of thing
A database trigger event watches a certain type of thing for changes. Define the type here.
Timezone selection
Override the backend trigger's timezone by setting an alternative timezone with a static or dynamic choice. For this setting to be available you must first enable the setting Enable timezone override controls in your app's general settings.
Other ways to learn
Last updated