Salesforce gives its users a plethora of tools to be used in managing Visualforce pages, formula fields, and other similar places. One of these tools is the global variable. What are global variables, and how do they work within the Salesforce platform?
Global Variable Definition
Global variable is a type of merge field that yields information about the organization or the current user of the platform. Each global variable is easily identified because it distinctly starts with a dollar sign “$”.
Global variables are used in conjunction with other merge fields to reference important data about the organization. Customized links, formulas, buttons, and Visualforce pages allow the use of various global variables.
Types of Global Variables
There are many types of global variables, and each one has a different function. Here are some of the most common ones, together with the information they give reference to:
- $Action – Common actions in Salesforce such as creating, updating, and removing accounts.
- $Component – Visualforce components
- $ComponentLabel – inputField component labels found on Visualforce pages
- $Api – URLs of various APIs
- $Cache.Session – accessing the session cache coming from Visualforce pages
- $FieldSet – defined field sets within the Salesforce org
- $Asset – for images and similar assets found under the Lightning Design System
- $CurrentPage – for Visualforce pages that are currently being used
- $Label – for custom labels
- $Label.Site – for standard labels located on a Visualforce page
- $Page – for any Visualforce page
- $Network – for the org’s personal community details
- $Organization – for the company’s profile
- $Profile – for the current user’s personal information and profile
- $Permission – for information about customized permission access
- $UserRole – data about the current user’s role within the org
Where Are They Used?
Choosing merge field types to add to custom components entails the use of a global variable. That way, the user can determine what type of data he needs to reference within these custom components. Global variables are allowed to be used in the following components:
- Process Builder
- Visual Flow
- Pages within Visualforce
- Apex triggers and classes
- Customized formula fields
- Validation Rules
Global variables for each place are dynamic; they might not exactly be the same. For example, global variables used in a Visualforce page would be different from those used in the Process Builder or custom formula fields.