Flow: How To Use Global Variables in Flow Builder ($Record)

Simply put, global variables capture various information at the moment the flow fires. Just like the recordId or $Record which captures the current record, you have other variables that capture who is the current user, what is the company, or when is the flow executed. You can easily identify a global variable in Flow Builder by the ’$” sign found at the start of its name (eg, $Record and $User)

Global variables are very powerful for building flow. Fortunately for us, they’re also easy to use, so let’s dive into what they are and how to use them in flows!

Explanation Of Each Global Variable

You can find the official explanations here, but again we want some really easy words and examples right? I will list them down in the order of most frequently used. (by me)

  1. $Record
  2. $Record__Prior
  3. $User / $UserRole / $Profile
  4. $Organization
  5. $Flow
  6. $Label
  7. $Permission
  8. $System
  9. $Api
$Record

What’s not to love about the $Record variable? It works just like recordId, and you don’ even need to configure anything! This variable only exists in autolaunch flow types (Anything except Screen Flow). You can use it to replicate IsChanged formula or update the record, but here are some important points to consider when using $Record:

1. If you want to update $Record in a before-save flow, simply use Assignment; But when using an after-save flow, you’ll need to use both Assignment and Update Records.

2. If you use $Record in a Create or Update Records, make sure you have “Filter inaccessible fields from flow requests” checked in the automation setting.
This is because $Record also includes system and read-only fields that your users cannot modify. This setting filters them out. Otherwise, the system might try to change those fields which would make the flow fail.

Use Case Example

Back To List

Important Setting To Enable

$Record__Prior

It’s an amazing new feature after Spring’21 release. Here is the summary:

  1. Only available in record-triggered flow type
  2. Only available when choosing “record is updated” or “record is created or updated”
  3. If the record is newly created, the values of this variable will be null
  4. If the field is not updated when the flow fires, that field in $Record and $Record__Prior will have the same value (only changed fields at the time the flow was triggered will have values in $Record_Prior that are different from $Record)

Use Case Example: IsChanged

* It does not matter which option you choose for “When to Execute Outcome” because of note #4 above.

Back To List

$User / $UserRole / $Profile

Like the names imply, You can access the information, role, or profile of the person who’s currently running the flow through these global variables.

Use Case Example

  • Show the current user’s name on a screen element
  • Check the user profile or role and set up different flow paths for each scenario

Back To List

$Organizaion

As you may have guessed, $Organization gives you access to your own company’s (organization) information. This is the information you can find in Company Settings in Setup.

Use Case Example

Display the company’s contact info on a screen element

Back To List

$Flow

Basically, $Flow allows you to reference a lot of the current information about the flow interview. To see what I mean, see the case examples below. Also, find more details in this Salesforce help document.

Use Case Example

  • Show the current status or stage of the flow
  • Send out a fault message to relevant teams when the flow fails

Back To List

$Label

You can check out what a custom label is in this article. My understanding is that labels work like snippets. You can create a label that contains a specific value, and reference that label to show the message.

Use Case Example: In Flow Editor

Back To List

Use Case Example: When Running Flow

$Permission

$Permission will return True/False depending on whether the user has access to a specific custom permission. Learn more about custom permissions in this Salesforce help document.

Use Case Example

If current user has access to FSL__Fill_in, it will return True.

Back To List

$System

The only thing that is available is $System.OriginDateTime, which is a static value of 1900-01-01 00:00:00.

Use Case Example

No clue 🙂 It can be used to calculate time difference, but there are many other ways to calculate time difference too….

Back To List

$Api

Absolutely no clue what the use case is and how can this help. It looks like a very developer’y variable. Check out this article if you want to learn more about $Api.

Use Case Example (Shared by Eric Smith)

One of the uses of the $API global variable is to get the correct URL for the current domain. I’ve used it in a few different components. Let’s Get Toasty! and How to Include Chatter Posts on Printable Views.

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

(Updated Apr. 17)

Back To List

Is This Helpful? Check Out Flow Use Cases Or Write Us One!
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Eric Smith

One of the uses of the $API global variable is to get the correct url for the current domain. I’ve used it in a few different components. Let’s Get Toasty! and How to Include Chatter Posts on Printable Views.

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