Using split by and database triggers in Bubble.io
In this Bubble.io tutorial video we demonstrate how you can separate a user's full name into their first name and last name using Split By and database triggers.
Split Full Names Instantly: Learn how to use split by and database triggers to automatically separate first and last names in Bubble.
Optimize Your App's Performance: Discover how to use database triggers to keep user data in sync without duplicating workflows, improving your app's efficiency.
Master Backend Workflows: See how to leverage backend workflows and database triggers to handle name updates seamlessly across your Bubble app.
Introduction to Split By and Database Triggers in Bubble.io
In this Bubble video tutorial, I'm going to show you how to split a full name into a first name and the last name and how to use database triggers to ensure that you're never caught out or you never miss out on a user updating their full name and then not updating the first name and last name fields.
Setting Up a Registration Form
I have a quick form here. I'm going to turn this into a registration form by adding a workflow onto the registration button. So account sign the user up and then email password and I'm going to add a new field called full name. I've got two full name fields because I'm going to demonstrate after this how to update full name and first name and last name and just do it really simply and quickly cut down on the number of workflows that you need to do this.
Creating a Database Trigger
This is only available on pay plans for Bubble. I go and create a database trigger. The database trigger allows you to run a workflow when information in your database is changed. I would call this update user name and the type is user. If I don't fill in this section here, and you can read all about this in the Bubble documentation, database triggers are immensely useful. It's really worth you getting used to them and building them into your app.
Benefits of Database Triggers
It basically means that you don't have to duplicate a load of workflows. Imagine you wanted to update your users' names on one part of the app but you also wanted to update them on another part. You'd end up duplicating your process to ensure that your full name and your last name and your first name are all in sync. Database triggers just do it automatically in the background.
Optimizing Database Triggers
If you don't fill in this section here, it's going to run every single time there's a change to the user, which is not great for your app's optimization because it's running it too many times. Even though we're doing a relatively small process, you want to build your app with optimization in mind. So I say when current user's full name is not user now full name. That's saying when the user's full name changes, run this workflow.
Splitting the Full Name
Then I go to make changes to current user. I like the naming convention like this because then it just groups it all together. So that's a first name and then that's the last name. How do I split it? I go user now full name and then I go split by space. Then I say show only the first item for the first name.
Handling Complex Last Names
For the last name, this isn't going to be perfect. There's lots you could get into here, for example, the fact that the whole first name last name convention is not used globally. Also, imagine if someone has got like a McDonald's but they put space between the Mc and the Donald on their last name. So what we'll do is we'll say full name split by space and then we'll say items from 2. We'll do that because we're basically saying that anything that isn't the first name is going to be put into last name.
Finalizing the Workflow
Just to be sure, we will add in the join with because I think by default Bubble will use a comma, but we're going to use a space. So that should, even if the person has put in three different words as their name, it's going to take the first name as the first word and then the following words it's going to put them as the last name. That's going to put space between them and that will run automatically in the back end of the workflow.
Testing the Registration Form
Let's go back to our page of names and let's preview. I'm going to put in my name Matt Blake and my address and password and then hit register. To see if that's worked, I'm going to add in some extra fields here. I'll say current user full name and a new line, I'll put current user first name new line current user last name.
Updating User Information
Let's see if that's worked. The registration flow has logged me in. You can see that it's split out all the different parts. Now what if I wanted to update it? This is the beauty of back-end workflows and using database triggers because all I need to do is update the full name.
Demonstrating Database Trigger Functionality
Account make changes to user full name equals full name field two. Let's go for Peter Parker, click update and you'll see that there's a brief delay but that's the database trigger. You saw that this updated first, that's because that's our workflow attached to here, and then when Bubble detects that full name has changed for the user, it will update it for the first name and the last name.
Conclusion and Further Applications
You can do any number of combinations of this. You could even reverse engineer this. So that you input, as is often the case, you might instead on your registration form have a first name and a last name, but you might have a part of the app where you want to display the full name and you always want to display the full name. So you could do this the opposite way round. You could store the first name and the last name and have a database trigger that combines them into the full name.
Anyway, there we have it. That is a quick overview of using split by and using database triggers to handle full names, first names and last names in Bubble.
Get the Complete Bundle for Just $99
Access 3 courses, 390+ tutorials, and a vibrant community to support every step of your app-building journey.
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 390+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.
Save over 70%!
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Have questions?
We have answers!
Find answers to common questions about our membership plans, programs, and more.
We're here to help you launch your no code SaaS. Reach out to the team and we'll double check our vast library for useful content. We'll advise you on how we'd tackle the same problem and there's a good chance we'll record the video to help the wider community.
As a Planet No Code member, you'll receive a discount on our Bubble coaching sessions. Monthly members receive a 10% discount, while Annual members receive a 17.5% discount. To redeem your discount, simply log into your account and book a coaching session through our platform.
Our 8-week intensive mentorship program is designed to provide personalized guidance and support to help you accelerate your startup journey. You'll be matched with a startup expert who will work with you one-on-one to set goals, overcome challenges, and make rapid progress.
To apply for the Mastery Program, simply click the "Request Invitation" button on our pricing page and fill out the application form. Our team will review your application and schedule a call with you to discuss your goals and determine if the program is a good fit for your needs.
We accept all major credit cards, including Visa, Mastercard, American Express, and Discover.
While we don't offer a free trial, we do provide a 14-day money-back guarantee. If you're not completely satisfied with your membership within the first 14 days, simply contact our support team, and we'll issue a full refund.