Canvas Documentation
Bubble Best Practices
v3.8
v3.8
  • Introduction
  • Key Features
  • What's New
  • Canvas Design System Figma File
  • CANVAS FUNCTIONALITY
    • Getting Started
    • Branding & Design
    • Marketing Pages
    • Bubble Pages & Blocks
    • Roles & Permissions
    • Menus & Navigation
    • Data & Workflows
    • Emails & Alerts
    • Privacy rule checker
    • Miscellaneous
      • Setting up two factor authentication
      • Cookie and consent banner
      • Setting your password policy
      • Set up Payment info on Account page
      • Loading screen
      • Configuring multiple languages
      • Customizing your app's portal page colors
    • Reference
      • Pages
        • Index
        • Admin Portal
        • Account
        • Login
        • Legal
        • Reset Password
        • 404
      • Reusable elements
        • Header
        • Footer
        • Signup & Login
        • Cookies Permission
        • Widgets
          • App security
          • Header Widgets
          • Workflow Widgets
        • Admin Portal
          • Admin analytics
          • Admin email & templates
          • Admin header & footer
          • Admin legal popups
          • Admin branding, launch, and settings
          • Admin marketing pages
          • Admin portal canvas logic
          • Admin options settings
        • Menu Focus Elements
      • Data types
      • Option Sets
      • Backend Workflows
      • Design standards
        • Manually Building UI
  • Bubble Best Practices
    • Learning Bubble Basics
    • Principles
    • Database
    • Design
    • Security
    • SEO
    • Speed
    • Modularity
      • Data triggers
  • Canvas library
    • Page templates
      • Free Bubble Marketing Page
      • Premium Bubble Marketing Page
      • Centered Profile Page
      • Left-Justified Profile Page
      • Standard page
      • Toggle Tabs Page
      • Menu Page
      • Mobile Menu Page
      • Video List Page
      • Standard Portal / Dashboard Page
      • Simple Portal / Dashboard Page with Icons
      • Double Sidebar Portal Page Template
      • Search Page
      • Map Search Page with Toggle and Filters
      • Floating Map Search Page
      • Search Bar Page
      • Multi-Step Page With Progress Bar
      • Standard Multi-Step Process Page
      • Multi-Step Process Page with Sidebar
      • Gallery Profile or Product Page
      • Sidebar Profile Page
      • 2-Column Menu Tabs Page
      • 2-Column Checkout Page
      • 2-Column Video Chat Page
      • Vertical Multi-Step Page Template
    • Blocks
      • Monthly Calendar Scheduling Widget
      • No Reply Comments Thread
      • Nested Comments Thread (with Like and Reply)
      • Placeholder Group
      • List with Circular Progress Bar Repeating Group
      • Top Input Chat Widget
      • Bottom Input Chat Widget
      • Toggle Tabs Group
      • Single-Select or Multi-Select Pill Tabs Group
      • Settings group
      • To-Do List Repeating Group
      • Title Group with Button and Filters
      • Product Details Group With Progress Bar
      • Listing details with Icons and Menu Focus Group
      • Week Daily Availability Group
      • Frequently Asked Questions (FAQ) Repeating Group
      • Dismissible Module
      • Video Group
      • About Group
      • Add to Cart Group
      • Full Width Map with Directions Link
      • Location Module (Map and Directions)
      • Drag and Drop Repeating Group
      • Infinite Columns Horizontal Scroll Data Table with Fixed First Column
      • Expiration timer
    • Popups
      • Confirmation Popup
      • Message Popup
      • Image Popup
      • Video Popup
      • Vertical Scroll Popup
      • Edit Popup
      • Standard Form Popup
      • Subscribe Popup
      • Feedback / Contact Popup
      • Details Popup
      • Add List Popup
      • Advanced Form Popup
      • Rating Popup
      • Toggle Tabs Popup
      • Share Popup
      • Multi-Step Popup
      • Invoice Popup
      • Stripe Credit Card Purchase Popup
      • View Profile Popup
      • Send Message Popup
      • Multi-Select Pill Tabs Popup
      • Pricing Plans Popup
Powered by GitBook
On this page
  • Common use cases
  • Linked data objects
  • Calculations
  • Generating an object JSON or other field that summarizes the object's contents
  • Performance
  • Limitations and workarounds

Was this helpful?

  1. Bubble Best Practices
  2. Modularity

Data triggers

Guidelines for use of Bubble's new data triggers, released for a public beta in March 2020

PreviousModularityNextPage templates

Last updated 3 years ago

Was this helpful?

This page will serve as a guide for Bubble's new - actions in the Backend Workflows page that will happen any time you make changes to a data object anywhere in the app. For example, when you add an object to a Cart, a data trigger workflow can automatically re-calculate taxes and any other calculated fields, eliminating the need to copy logic to many places throughout the app.

Before starting this guide, be aware that it is best to wait at least a few weeks after a feature like this is released before including it for mission-critical features in a client app. Since it was only just released as a public beta, it is possible that the feature is not yet production-ready or that some bugs will be found in the following weeks.

Common use cases

For all of the below use cases, they're really only relevant if a data type is being changed in more than one place in your Bubble app. If you're considering moving workflows to a data trigger, and the trigger is only run from one place in the app, it's best to stick to normal workflows.

Linked data objects

Updating one object when another directly related object is changed.

For example: a taxi Driver has a Car in a ride-sharing app. When the Car is updated, say if a car becomes too old to be eligible for the app, the Driver can also be updated - in this case, to be unavailable for future rides.

Data can be linked in many different ways, including:

  • Bidirectional linkages (like the above Driver example)

    • Data from one object is directly linked to another, and vice versa

  • One-to-one linkages for CSV exports

    • Data from one object is directly linked to another, and you want to replicate saved data in order to more easily export it as one table.

    • Imagine that in a Bubble app, each User has a Store, and each Store has a monthly revenue. In a data export of Users, normally the only field included from the Store would be the Store's unique ID. We can include each User's Store's monthly revenue on a second monthly revenue field on the User object. That field will also be included in the CSV export. However, the User's monthly revenue field will also need to be updated each time the Store's monthly revenue field changes. Using a data trigger here would make since if a User can make changes to a Store's name in multiple places in the app.

  • Roll-up/summarized data

    • Imagine that there is a Repeating Group of Users and their number of Items is displayed as a column in the UI. Rather than using a do a search for Items:count call in each row and calculating the number of items, a number field named Item Count can be recalculated each time an item is added/removed. Again, this makes most sense if the number of items can be changed in many places in the app. If it is only changed in one workflow, you can add the step to save the number of items on the User object inside that same workflow.

Calculations

Running complex calculations that need to be updated whenever a field is changed.

For example: financial calculations, or any formula containing many factors, where the result should be stored as a field.

Note the conditions here - if the calculations are already updated, there is no need to write to the database.

The second step takes the results of step 1 and combines them in a way that would be difficult to build and difficult to understand with Bubble mathematical logic.

Generating an object JSON or other field that summarizes the object's contents

Re-generating a field that reformats information from other fields. This is similar to the calculations, but generates a text output instead of a number output.

For example: a JSON that represents an object and contains each of the other fields, but is stored as a text.

This User JSON can be used to manipulate User data on the page with Javascript, among other things.

Performance

Overusing this feature can have huge impacts on app performance. Completing actions that take up a lot of capacity are not recommended, such as making changes to a list of many things.

Additionally, searches for data that are completed here do NOT have restrictions with privacy rules. Any search that is completed here can return an entire table in the database if it's not set up correctly, potentially using up your app's capacity and slowing it down drastically.

Limitations and workarounds

  • User-specific info:

    • Logging out of a User's account (using the Bubble "Log a user out" workflow) activates any User data trigger.

    • Logging into a User's account doesn't activate a User data trigger.

    • Signing up as a new User activates a User data trigger.

  • One data trigger can't trigger another data trigger - if I edit a User's Post's in a User data trigger, Post data triggers will not be activated.

    • Workaround: schedule an API workflow that makes changes to an object. This will trigger the data trigger for that object. (Functional as of May 13, 2020.)

      • There seems to be a protection against infinite loops here. If a User is modified in your app and the User trigger is activated, which then edits a Post in an API workflow, then the Post data trigger will then be triggered. However, if you then edit the User object in an API workflow triggered from the Post data trigger workflow, the User data trigger won't be activated, preventing a loop of User->Post->User->Post from continually firing.

data trigger actions
Fields made for CSV export could benefit from data triggers