Creating Dynamic Record Links
In this episode of Build It With Tim, we're addressing a common query: how to create dynamic record links sent via email that lead recipients back to specific record details within your application. This functionality is invaluable, especially in contexts like project management, where sharing specific project details is crucial.
Goal: The goal is to send email notifications containing links to view specific record details within your Tadabase application. Whether it's projects, events, users, or any other entity, the aim is to generate accessible links for recipients to directly access the detail page of a particular record.
Instructions:
-
Understanding the URL Structure: To create these dynamic links, understanding your application's URL structure is essential. URLs comprise the root domain, the application name (or custom domain), the page slug (representing the current page), the detail page slug, and the record ID.
-
Setting Up Fields:
- Create a text field to store the record ID.
- Create a text formula field that contains the base URL of your detail page without the record ID + the text field that stores the record ID.
-
Populating Record ID: Populate the record ID text field through table rules or record rules, ensuring it captures the unique record identifier.
-
Configuring Email Notifications:
- Choose the page where records are added (e.g., an "Add Projects" form).
- Navigate to the notifications tab and create a custom email.
- Construct your email message, incorporating dynamic fields from your data table (project title, manager, etc.).
- To add the dynamic link, use the "Insert/Edit Link" option, referencing the field containing the URL. This ensures the link in the email corresponds to the specific record.
- Test the setup by submitting a new record. Upon submission, an email will be sent containing the record details and the dynamic link leading back to the record's detail page.
This process seamlessly integrates into your workflow, allowing you to efficiently share specific record details with stakeholders via email. Implementing this feature enhances your communication and collaboration capabilities within Tadabase.
Features Discussed:
-
URL Structure (Timestamp: 1:43)
Learn how to dissect the URL structure of detail pages, including identifying the page slug and record ID. This understanding is crucial for creating dynamic links that direct users to specific records in your application. -
Setting Up Fields (4:00)
Learn how to create and configure text fields and text formula fields to build dynamic URLs that link directly to the detail pages of records. This involves storing the base URL and appending the record ID to form complete, accessible links. -
Record ID (4:58)
Learn methods for populating the record ID field using table rules or record rules, ensuring that each record has a unique, identifiable URL that can be used in email notifications or other functionalities. -
Email Notifications (6:07)
Learn how to set up custom email notifications that include dynamic links to specific records. This includes adding fields from your data table into the email body and inserting the dynamic link that was created earlier. This ensures that recipients can directly access the relevant detail pages from their email.
Transcript Summary
Introduction
Hey everybody, this is Build It with Tadabase. I've got a quick tip for you today, but it is incredibly handy, useful, and I see it being asked a lot.
Scenario Setup
Let me paint a little picture for you. Inside your application, you are submitting new records for some kind of object or entity. In this case, we are talking about project management, so we are submitting new projects. When I submit a new project, I want to send an email notification with a link to view the details of this particular record.
What I mean by that is if we take a look at this table component that is displaying all of our current projects, if I click on the details link, it's going to take us into the detail page to view the details of that particular project. Now, this doesn't have to be for projects specifically; it could be for anything—events, users, customers, products, companies, it doesn't matter. The point here is that we're talking about a detail page that displays information about one particular record.
Understanding the URL Structure
How would I create a link that I could then send out when creating a new record, allowing users to come directly back to the detail page? Before we get into that, we need to dissect the actual page URL a little bit to help us understand what's happening here.
Let's go back a step onto the actual projects page and then open up that URL once again. If we take a look at our full URL that's in the address bar of our browser, we have our account (e.g., account.tadabase.io
). This could also be a custom domain if you are using one, but this is the root of our actual application. Then we have the name of the application. If you're using a custom domain, you're not going to see the name of the application. Instead, the next thing you will see is the page slug. The page slug tells us which page we are currently viewing. This could say login, sign up, projects, home, customers, companies—whatever it is, it is the parent-level page that is currently representing what we are looking at.
If you're familiar with our API or anything like that, then you've likely seen record IDs and table IDs before. In fact, you may have even seen them and never realized it. If we head back to the Builder here and we take a look at our projects data table and once again inspect that URL, we even have a table ID listed right here and an app ID listed right there. So there are lots of IDs being generated behind the scenes, but the one we want to focus on today is the record ID.
Building the Link
In order to build this link, we're going to need two things: the record ID and the URL of the detail page minus the record ID. I'm going to go back to this page, highlight the URL, and copy it. Then I'll go back into my projects data table and add two new fields.
The first one is going to be a text field, which I'll call "Record ID." The second one is going to be a text formula where we paste in our URL from the detail page—minus the record ID. We're going to remove the record ID but ensure that there is a slash still at the end of that string.
Once we add it, you'll see that we now have what would be known as our base URL. Then we can simply add the record ID field at the end to complete that full URL and build the link. If we take a look at this text formula right now, you'll see there's no record ID at the end. First, we actually have to populate that value into our record ID text field.
Populating the Record ID
There are two ways to populate the record ID. Typically, the first would be through the use of table rules in the Data Builder. The second would be through the Page Builder using a form component and record rules. You can do the same type of logic inside record rules as well.
I typically like to do it inside table rules, so I'll do it here. We'll say, "When a record is created or edited"—in this case, I'm going to choose created or edited because I want to update these historical or existing records with the record ID. Then I'm going to set the record ID text field to a record value of "Record ID." In this dropdown, we have all the available fields inside our table, plus this hidden one generated behind the scenes, which is the actual Tadabase record ID.
I'll save that rule, go back to my records, and simply edit this record in any way just to trigger that rule and populate our text field. Going back to our text formula field after refreshing the table, you'll see we now have a completed URL.
Sending the Email Notification
The next step is to actually email this out. We'll pick a page where projects are being added. In our case, it's under the project manager layout, on the projects page, with a child page called "Add Projects," which is a form to add a new project record. I'll click into that form, then click on the notifications tab, make sure emails are selected, and choose to add a new email. I need to change this from basic email to custom email, then start configuring the email notification that I'm going to send.
For testing purposes, I'm going to send it to myself. Then I'll fill out the rest of the subject and the message. Let's start with our subject: "New Project Submission: Action Required." Then we can start building out our actual email message, but I've already done so once, so I'll paste it in here and explain what's going on.
We'll start off with just our welcome message in the email body. Then we can start to include fields from our data table. What that looks like is by clicking the "Add Field" button up here in the top right corner, we can choose any of the fields from our table that are available in this dropdown to add to our email body. When they are added, you'll see that they are wrapped in an open curly bracket and a closed curly bracket. This indicates that this is a dynamic field being referenced from our data table.
I've included things like the project title, the project manager, the project description, as well as the project manager once more here. Then I have a link at the bottom that says "View Project." The way you can build these links and include that text formula is by clicking on the "Insert/Edit Link" button at the top of the editor. We can then insert that dynamic field value by using an open curly bracket, the name of our field that contains that link, and a closed curly bracket. Then I can just give it text to display, decide whether I want to open it in a new window or not, and now we have our link.
If we look at the actual HTML behind the scenes, you can see that this value here is included as the actual link URL that's going to be sent.
Testing the Functionality
By updating and saving this, our email is now complete. To finish off this video, we're going to quickly test this function we've built. I'm going to refresh the page to make sure everything has taken effect, and then simply add a new project.
I'll give it a title, a description, and select a project manager. When I click save, what's going to happen is this: the record is going to be created, the table rule will be triggered, it will populate our record ID field with the Tadabase record ID, and that will be concatenated inside the text formula field we set up. The end result will be a fully accessible URL to the detail page of this project. After all that is done, the email notification will be sent out as we configured it, including the details link we created.
I'll click save now, and all that processing is done. If I check my email, you'll see that I already have an email with all this data: test project submitted by this user, the description, and at the very bottom, the link that takes us back to the detail page. I click that, and it takes me right back into my application, allowing me to view the details of the project we just submitted.
Conclusion
That's it for this week's episode of Build It with Tadabase. It's a really quick tip, like I said before, but it is super handy when you need to send out those links and bring people back into your application. Thanks so much for watching. I hope you found it useful, and we'll see you next time. Take care.