Headshot of Mary Tagler next to copy that says, "Automate This! — Track Your Blood Pressure with Flow."

Automate This! — Create a Blood Pressure Tracker Using Flow and Custom Notifications

By

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, see how Mary Tagler uses Flow, custom notifications, and image formula fields to create a blood pressure tracker to stay on top of her health.


Use case

A few years ago, I was diagnosed with high blood pressure. Prior to this, I didn’t understand which readings were good or bad and only checked it when I went to a doctor’s appointment. After the diagnosis, I realized that checking my blood pressure regularly had to become routine. I wanted a solution where I not only owned my data but also could customize the tracker to meet my needs.

To solve for this, I decided to build a solution in my personal Developer org. Over the years, I’ve used Salesforce Dev orgs for a lot of hobby projects (including wedding planning) because they allow me to not only solve problems but also grow my professional skill set. Using a custom object, a few flows, and some added bells and whistles, I built a blood pressure tracker that checks all of my boxes and allows me to quickly show my doctor recent blood pressure trends.

Solution

1. Create a blood pressure object

The first step was to identify important data points to track my blood pressure. I created a blood pressure object with the following fields to support my tracker.

  • Systolic — The upper number of your blood pressure reading
  • Diastolic — The lower number of your blood pressure reading
  • Reading — Systolic/Diastolic (You’ll want to express this as text, so you don’t wind up with a decimal number.)
  • Reading Date — The date and time when the reading was taken
  • Level — An image formula field that matches the reading to the American Heart Association’s (AHA) blood pressure chart
  • Next Reading Due — The date and time when a recheck should be completed

Below is a sample Blood Pressure record.

The Blood Pressure record showing an entry, the color-coded level of the reading, as well as the reading itself and the Reading Date and Next Reading Due fields.

2. Build a screen flow

Technically, the object alone was sufficient to track blood pressure, but it didn’t meet all of my objectives. Specifically, I wanted to:

  1. Be able to easily compare my current reading to my last reading.
  2. Create reminders, so I’m checking my blood pressure consistently to ensure my blood pressure is well controlled.

Before we dive into the detailed elements, here’s an overview of what our flow will look like.

Blood Pressure Screen Flow with the following elements in order: Get Records for Blood Pressure records, Screen to enter info, Create Records to create a Blood Pressure record, Get Records to get the just-created record, and a Show Toast Action.

To fulfill my first requirement, I started my flow by locating my most recent blood pressure reading using a Get Records element by finding the record with the most recent reading date.

Get Records flow element that gets the Blood Pressure records sorted by Reading Date in descending order and returns the first record.

Next, I built my screen flow and divided it into two sections. The first section uses display text, reflecting my most recent blood pressure reading. The second section contains the inputs I need to create a new Blood Pressure record.

Screen flow element showing the Last Reading and collecting a new blood pressure reading.

For my reading date, I set the default value to the current date and time using the global variable $Flow.CurrentDateTime. Using the screen inputs above, I create my new Blood Pressure record.

Create Records element showing the assignment of the screen inputs to their respective fields.

One enhancement I made to this flow was to add a custom Show Toast component. UnofficialSF provides custom community-built components to enhance your flows, as well as useful blog posts on Flow features and use cases. If I’m trying to solve a problem and solve for it natively in Salesforce, it’s the first place I look. Note: Custom components from UnofficialSF have not gone through Salesforce security review. Always install these components in a sandbox first. Your developer should perform a code review of the component and test class, making any needed updates to adhere to your company’s coding standards and code coverage prior to use in your production org.

To use the Show Toast component, I used another Get Records element to grab the record name from the Blood Pressure record created earlier to reuse in my flow. The {url} variable merges my URL into the Message field as noted.

how Toast element and inputs; the Show Toast action comes from UnofficialSF.

Formula resource behind the URL token in the Toast prompt that allows users to navigate to the triggering record.

With this fURL formula resource, you can insert an ID variable at the end, where we have {!getNewBP.Id} and it will concatenate the current domain with the record ID you want to navigate to.

LEFT({!$Api.Partner_Server_URL_340},FIND("/services", {!$Api.Partner_Server_URL_340})) & {!getNewBP.Id} >

The resulting Toast prompt looks like this:

‘Success’ Toast message with a link to the Blood Pressure record.

With just a few elements, we’ve created a screen flow to enter Blood Pressure records.

3. Set the next reading date

I still needed to set the Next Reading Due value, to solve my second requirement. I could have populated this value in my screen flow, but I opted to use a record-triggered flow instead. I wanted to ensure that regardless of how the record was created (via screen flow, via cloning, or from a list view’s New button), the field value would be properly set.

Record-triggered flow with a Run Immediately branch and a scheduled branch called Notifications.]

My record-triggered flow runs when a record is created or edited, when there is a new record, or when the reading date is updated.

Start element showing the flow running on create and update with formula entry criteria.

For my immediate path, I want to set the next reading due based on my blood pressure reading. The AHA blood pressure chart is color-coded, with green representing optimal blood pressure levels and red representing dangerous blood pressure levels. All of that goes to say, the higher my blood pressure, the sooner I want to recheck it. To do this, I created a formula variable to mimic the blood pressure chart and populated that date and time to my Next Reading Due field.

Update Records element showing that Next Reading Date is being set by a formula variable.

The formula below represents the recheck cadence I created for myself.

IF(
 AND(
  {!$Record.Systolic__c} < 130,
  {!$Record.Systolic__c} > 119,
  {!$Record.Diastolic__c} < 80
 ),
 {!$Record.Reading_Date__c}+ 10,
IF(
 OR(
  AND(
   {!$Record.Systolic__c} < 140,
   {!$Record.Systolic__c} > 129
  ),
  AND(
   {!$Record.Diastolic__c} > 79,
   {!$Record.Diastolic__c} < 90
  )
 ),
 {!$Record.Reading_Date__c}+ 7,
 IF(
  OR(
   {!$Record.Systolic__c} > 139,
   {!$Record.Diastolic__c} > 89
  ),
  {!$Record.Reading_Date__c} + 3,
  IF(
   OR(
    {!$Record.Systolic__c} > 179,
    {!$Record.Diastolic__c} > 120
   ),
   {!$Record.Reading_Date__c} + 1,
   {!$Record.Reading_Date__c} + 14
))))

To simplify the formula, here’s a table that maps the level color to the recheck cadence.

Table outlining the level color and the corresponding recheck days.

4. Schedule notifications

Building new habits is hard. Making blood pressure tracking part of my routine was much harder than I expected, so I revised my record-triggered flow to add a scheduled path for notifications.

Before returning to my flow, I had some prep work to do. I created a custom notification to send in-app notifications to my desktop and mobile devices. If you opt for mobile, there are two steps you must complete. First, navigate to Custom Notifications from the Setup Menu and click New. Name your notification and set the notification channels. For mobile notifications, you must also go back and edit the notification to set whether notifications are available on Apple or Android mobile apps. Additionally, because it’s bad practice to hard code IDs, I created a custom label to store the ID of the notification.

I returned to my flow and created a scheduled path called Notifications that runs 0 minutes after the Next Reading Due field.

Scheduled path showing the notification branch triggering 0 minutes after the Next Reading Due date/time.

To use the Send Custom Notification action, you must have the recipient IDs stored in a collection variable. For this use case, I want to send the notification to the creator of the record, so I assigned the CreatedBy User ID to vRecipientId, the collection variable I created. I also created a variable called vRecipientEmail to use later in my email action.

Assignment element showing that the ID of the creator is being added to the collection variable.

At this point, I can add the Send Custom Notification action to my flow. To support this notification, I’ve also created a text template variable, which contains the alert message and sets a title for the notification. To control where the user is directed on selecting the notification, I’ve set the target destination to the record that triggered the flow.

Send Custom Notification action; a custom label is used instead of hard coding the notification ID.

The resulting notification looks like this and will redirect to the record that triggered the notification on selection.

Notification in action from the user’s view.

I also added an email alert in the event I miss the in-app notification. To do this, I used the Send Email core action, which does not require an Email Alert or Template. You could just as easily use the Email Alert based action instead if you prefer. I specify my recipient in the Recipient Address Collection field using the variable vRecipientEmail that I set in my Assignment element above.

The Send Email core action set to send to the record creator as a rich text email.

Let’s recap

With a custom object and a few flows, we’re able to create an efficient and useful blood pressure tracker! We can use the data generated to monitor our health and continue to extend the functionality, whether we’re creating custom reports, dashboards, or an application.

Resources

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
Use Flows and Experience Cloud to Access Salesforce Scheduler.

Use Flows and Experience Cloud to Access Salesforce Scheduler | Automate This!

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, learn how Lynn Guyer requests support from […]

READ MORE