Global variables are system-provided variables that reference information about the Salesforce org or running user. For example, current user’s ID or the API session ID.
There are a few different global variables that you can reference in the flow.
1- $Api
It references an API URL or the session ID.
2- $Client
This global variable is available only in Lightning Scheduler flows and supported only in Decision elements. Depending on the device that is running the flow, $Client.FormFactor value is automatically set to Large for desktop, Medium for tablet, or Small for phone. While building a flow, you can use a decision element to create separate paths for form factors (device types).
3- $Flow
It references information about the running flow interview.
Values that you can reach using the $Flow global variable are:
$Flow.ActiveStages
$Flow.CurrentStage
$Flow.CurrentDate
$Flow.CurrentDateTime
$Flow.CurrentRecord
$Flow.FaultMessage
$Flow.InterviewGuid
$Flow.InterviewStartTime
In flow formulas, TODAY() and NOW() functions cannot be used. Instead, you can use $Flow.CurrentDate and $Flow.CurrentDateTime global variables.
4- $Label
This global variable references custom labels and appears only if your org has custom labels.
The returned value of this global variable depends on the language setting of the user. The value returned is one of the following, in order of precedence:
- The local translation’s text
- The packaged translation’s text
- The master label’s text
5- $Organization
It references information about your company, such as the Country field. You can reference this value using {!$Organization.Country}
6- $Permission
It references information about the current user’s custom permission access.
7- $Profile
This global variable references information from the current user’s profile, such as license type or name.
8- $Record
This global variable is available only in autolaunched flows with triggers (record triggered or scheduled flows).
In a record-triggered flow, the $Record
global variable contains the triggering record’s values. You can reference and change these values throughout the flow.
9- $Record__Prior
It is available only in record-triggered flows that are configured to run when a record is updated or when a record is created or updated.
The $Record__Prior
global variable contains the values that the triggering record had immediately before the flow started. You can reference these values but cannot change them in the flow. When the flow is triggered on create, all $Record__Prior
values are null since the record is new and there cannot be a prior value.
10- $Setup
To access custom settings of type hierarchy in flows, you can use $Setup global variable. This global variable appears only if your org has hierarchy custom settings. If you need to access custom settings of type list
, you have to use Apex.
11- $System
To perform date/time offset calculations, you need the literal value of 1900-01-01 00:00:00 which is stored in $System.OriginDateTime global variable.
12- $User
This global variable references information about the current user. Current user is the user that caused the flow to run. For example, $User.Id references the user’s ID.
13- $UserRole
This global variable references information about the current user’s role, such as the role name or ID.
Usage of Global Variables
In screen component visibility conditions, only $Flow global variable can be used, the other global variables are not available. If a field in the database has no value, the corresponding global variable returns a blank value.
Global variables can be used in get, create, update and delete actions. In the example below, account owner is updated to the current user by using $User.Id global variable.
Leave a Reply