Forum Academy Marketplace Showcase Pricing Features

Workflows for Fields and Data Types

Have you @emmanuel ever thought about creating workflows for Fields and Data Types?

Let’s call it “Data Workflows”

The idea here is to be able to double-click on the data type or its fields to bring the workflow screen specific for these objects (and also have a data workflow tab). This would allow us to create workflows for data manipulation system-wide, saving us the trouble of having to worry about these rules and actions for every page you create.

In my applications for example, if a person was less than 18 years-old at the time of arrest, his records cannot be displayed anywhere to anyone. So, in all the reports and data views I create, I always must remember to add this extra logic to make sure “minor” cases are not displayed.

But with Bubble’s new Data Workflow, I could just go to “Data Type Workflow” and add an action to HIDE all records where defendant’s age is less than 18 years of age at the time of arrest.

So, imagine I could go to “DATA” tab and double-click on my “Defendant” table and click on “add/edit workflow” for my entire table. Then I could enter the following condition (or rule):

If Defendant.Age_at_Arrest < 18

And the following action:

“hide record from all”

Another example could be for a web app that sells alcoholic beverages, or adult material. You could just go to your data tab, user table, add a field for “Age”, double click on it and enter the following workflow:

Rule: If User.Age < 21

Action: ERROR ‘You must be 21 years old or over to continue’

So, no matter which screen you create, if the user’s age is created or modified to be less than 21 years of age, an error would be generated.

Another example:

LineItem.Total = LineItem.Price * LineItem.Quantity

Define calculated fields. In this case, there is no condition. Just an action based on other fields. Whenever Price or Quantity gets added/changed, Total gets updated. You never have to worry about it again on any screen:

Another example:

Condition: Reservation.Status CHANGES TO ‘New’
Action: SEND ReservaitonOfferEmail TO Reservation.Member

You just set this once at the data level. Now, whenever the status of any of your members or client’s reservation changes to NEW, an email is sent to them automatically. No need to worry about it in different pages.

Another example:

Client.FullName = Client.FirstName+’ '+Client.LastName

Anywhere in your app, when Last, First is added/changed, it updates The “FullName” field.

The applications are endless…

Let me know what you all think.

You can currently achieve this by using filters when performing a search. In a Repeating Group for example, you’d create a search for users with age > 16.

Most things you suggest can be achieved this way, since Bubble is very declarative - if you have a Total field on a page and the data changes, the system automatically updates it behind the scenes. Create a label with a user’s Info field displayed and change the data for Info while you have a preview page open - you’ll notice it auto-magically updates :smile:

Reusable components make it easy to use the same filter on all pages - once a Group Layout is created with that filter, make it into a reusable component and reuse it across all pages.

Sending an email on data change can also be done, but by using the source trigger, when the trigger is a user. How does the data change? If it’s a user who acts through a Bubble app, you can set up a workflow - e.g. when the user updates their name, send them an email.

Are you trying to achieve something this functionality isn’t sufficient for?

You missed the point.

Of course all the things I suggested can be achieved at the component level. And then one can create reusable components with a declarative statement and, every time you use that component, the data will automatically change. But that is only if you use that component.

I am talking about Business Rules. Rules that pertain to how your business work. It is a global set of conditions that you need to setup at the data level. Not at the page or component level. You just want to create it once.

In your example, I would have to always pick that component in order to work. But you need to create other types of repeating groups where the type may not be the “User” or the data source may not be “Search for Users…”.

That is the problem. You have to keep creating these conditions for everything you do.

But when you create a workflow at the data level, you only do it once. You never have to worry about it again, no matter what you do on a page.

And that is my point: Just create it once. Making Bubble even more powerful and easy to use.

You can do this at the security level, restricting who can see what based on some rules. This saves you the work of having these conditions in each search. This is an advanced feature though, and I wouldn’t recommend using that at first, since it will hide search results and can be hard to debug when you’re building your app.

Where is this security level?

I could not find it in the documentation.

Thanks.

It’s in the data tab (i think that were it makes most sense). See this https://bubble.io/reference#Data.Privacy

I see - you’re suggesting something akin to triggers and stored procedures on a database, so you don’t have to create them again for each component and workflow - is that correct?

That is correct @georgeciobanu

I see it now @emmanuel. Sorry, I saw that role button but did not think of clicking on it (I wasn’t thinking about roles, but workflows or rules)…

But WOW! Is there anything you guys haven’t thought of? :heart_eyes:

This is almost what I was talking about. It does allow me to create conditions at the data level to restrict some data access.

Example:

  1. Some attorneys that work as a prosecutors now work for public defenders. When they do that, they are not allowed to see cases where they were assigned as the prosecutor in the public defender database. I can easily do that at the data level using your roles now, so I never have to worry about it again. Thanks!

  2. Attorneys are allowed to see memos/notes for other attorneys, but they are not allowed to edit them. This “data role” will allow me to simply set this rule. Thanks again! :grinning:

You guys are almost there! How about adding a little bit more? The power of your workflows right in the data types?

:wink:

For example: I create a field in the “User” data type called “Security Level”.

Now I want to setup the following…

I highlight my “Case” Data Type and define the following “Role”:

If the field “Defendant_Age_at_arrest” in the Case data type is < 18 and Current user Security Level <> “Administrator” then “Find this in Searches” textbox is uncheck. In other words, only administrators can see a case record if this is a Youthful Offender.

Currently I can only compare fields from a table to itself or the current user. There is no way to use arithmetic operations.

So, I currently cannot also set a field based on calculations of other fields…

Example: LineItem.Total = LineItem.Price * LineItem.Quantity

This is not really a role, or a set of security rules, it is just a business logic (or a trigger like @georgeciobanu suggested) that you always want to update a field if some others change its value, no matter where you are in your application.

Man, but this Role thing is really close. Great job guys!

Do you know there are some programming companies advertising how great they are mostly on this ability of creating Business logic, processes, rules right at the data level? They have nothing else you have (still have to use CSS, HTML, fixed-based control placement, etc…) but they think they are great just because they have a powerful logic building engine at the data level. :confounded:

I know this is old, but is would still be a tremendous timesaver. Workflows that would execute on create, update, delete such as creating a incremental job# or calculating invoice line items regardless of what user-facing action actually triggered it, would eliminate a lot of redundancy for me.