Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
DictionaryGGlobal Variable
DevelopmentIntermediate

Global Variable

In Salesforce formulas, Visualforce, and Lightning components, a system-provided variable (prefixed with $) that gives access to contextual information like $User.Id, $Profile.Name, $Organization.I…

§ 01

Definition

In Salesforce formulas, Visualforce, and Lightning components, a system-provided variable (prefixed with $) that gives access to contextual information like $User.Id, $Profile.Name, $Organization.Id, or $Label values.

§ 02

In plain English

👋 Study buddy

A Global Variable in Salesforce formulas, Visualforce, and Lightning is a system-provided variable starting with $ that gives you context info. Things like $User.Id (current user's ID), $Profile.Name (current profile), $Organization.Id (current org), or $Label.MyLabel (a custom label).

§ 03

Worked example

scenario · real-world use

The admin at Sortilege Hospitality builds a formula field on the Reservation object that records who created the record and when, using Global Variables: $User.Id returns the current user's Id, $Organization.Id returns the org Id, $Profile.Name returns the current profile, and NOW() returns the timestamp. A separate Visualforce page uses {!$Label.WelcomeMessage} to display a custom label, localized via Translation Workbench. Global Variables are how formulas, Visualforce, and Lightning components access platform-context info without queries - they're already-resolved at render time.

§ 04

Why Global Variable matters

In Salesforce formulas, Visualforce, and Lightning components, a Global Variable is a system-provided variable (prefixed with $) that gives access to contextual information about the running user, profile, organization, or system. Common global variables include $User (current user info), $Profile (current profile), $Organization (org info), $Label (custom labels), $Setup (custom setting values), $Permission (custom permissions), and $Site (current site context).

Global variables are essential for building dynamic, context-aware logic without hardcoding values. For example, a validation rule might use $User.UserType to apply different rules to internal versus external users; a Visualforce page might use $Label.WelcomeMessage for translatable text; a Lightning component might use $User.Id to filter data to records belonging to the current user. Knowing the available global variables and how to use them makes formulas, validation rules, and components more flexible and maintainable.

§ 05

How organizations use Global Variable

TerraForm Tech

Uses $User.ProfileId in validation rules to apply different validation logic for sales reps versus managers.

NovaScale

Localizes their Visualforce pages with $Label references to custom labels, supporting multiple languages without code changes.

CodeBridge

Uses $Setup global variable in formulas to reference custom setting values, keeping configuration outside of formula code.

Was this entry helpful?
Help us write better definitions. Quick reactions or detailed edit suggestions.
§

Test your knowledge

Q1. What's a Global Variable in Salesforce?

Q2. What's an example of a global variable?

Q3. Why use global variables?

§

Discussion

Loading…

Loading discussion…