You are here:
Global Variables
When you work with components such as custom buttons and links, formulas in custom fields, validation rules, flows, processes, and Visualforce pages, you can use special merge fields to reference data in Salesforce.
Required Editions
| The availability of each global variable depends on the experience and edition requirements for the related feature. |
| User Permissions Needed | |
|---|---|
| To create, edit, and delete custom s-controls, formulas, or Visualforce pages: | Customize Application |
| To edit flows and processes: | Manage Flow |
Use these global variables when choosing a merge field type to add to your custom component:
$Action
All objects support basic actions, such as new, clone, view, edit, list, and delete. The $Action global also references actions available on many standard objects. The values available in your organization can differ depending on the features you enable.
$Api
$Component
$ComponentLabel
$CurrentPage
$CustomMetadata
$FieldSet
$Label
$Label.Site
Salesforce provides these labels:
| Label | Message |
|---|---|
| authorization_required | Authorization Required |
| bandwidth_limit_exceeded | Bandwidth Limit Exceeded |
| change_password | Change Password |
| change_your_password | Change Your Password |
| click_forget_password | If you have forgotten your password, click Forgot Password to reset it. |
| community_nickname | Nickname |
| confirm_password | Confirm Password |
| down_for_maintenance | <i>{0}</i> is down for maintenance |
| email_us | email us |
| enter_password | Did you forget your password? Please enter your username below. |
| error | Error: {0} |
| error2 | Error |
| file_not_found | File Not Found |
| forgot_password | Forgot Password |
| forgot_password_confirmation | Forgot Password Confirmation |
| forgot_your_password_q | Forgot Your Password? |
| get_in_touch | Please <a href="{0}">{1}</a> if you need to get in touch. |
| go_to_login_page | Go to Login Page |
| img_path | /img/sites |
| in_maintenance | Down For Maintenance |
| limit_exceeded | Limit Exceeded |
| login | Login |
| login_button | Login |
| login_or_register_first | You must first log in or register before accessing this page. |
| logout | Logout |
| new_password | New Password |
| new_user_q | New User? |
| old_password | Old Password |
| page_not_found | Page Not Found |
| page_not_found_detail | Page Not Found: {0} |
| password | Password |
| passwords_dont_match | Passwords did not match. |
| powered_by | Powered by |
| register | Register |
| registration_confirmation | Registration Confirmation |
| site_login | Site Login |
| site_under_construction | Site Under Construction |
| sorry_for_inconvenience | Sorry for the inconvenience. |
| sorry_for_inconvenience_back_shortly | Sorry for the inconvenience. We'll be back shortly. |
| stay_tuned | Stay tuned. |
| submit | Submit |
| temp_password_sent | An email has been sent to you with your temporary password. |
| thank_you_for_registering | Thank you for registering. An email has been sent to you with your temporary password. |
| under_construction | <i>{0}</i> is under construction |
| user_registration | New User Registration |
| username | Username |
| verify_new_password | Verify New Password |
$Network
$MessageChannel
$ObjectType
$Organization
| Description: | A global merge field type to use when referencing information about your company profile. Use organization merge fields to reference your organization’s city, fax, ID, or other details. |
| Use: |
|
| Validation Rule Example: | Use organization merge fields to compare any attribute for your organization with that of your accounts. For example, you may want to determine if your organization has the same country as your accounts. This validation formula references your organization’s country merge field and requires a country code for any account that’s foreign. |
| Flow Example: | Create a flow formula (Text) whose expression is {!$Organization.City}. In a
Decision element, check whether a contact’s city matches that
formula. |
| Visualforce Example: | Use dot notation to access your organization’s information. For example: |
| Tips: | The organization merge fields get their values from whatever values are currently stored as part of your company information in Salesforce. Note that |
$Page
$Permission
$Profile
| Description: | A global merge field type to use when referencing information about the current user’s profile. Use profile merge fields to reference information about the user’s profile such as license type or name. |
| Use: |
|
| Validation Rule Example: | This validation rule formula references the profile name of the current user to ensure that only the record owner or users with this profile can make changes to a custom field called Personal Goal: |
| Flow Example: | Create a flow formula (Text) with this expression. By referencing that formula, you avoid using a query (Lookup elements) and save on limits. |
| Visualforce Example: | To return the current user's profile, use this: |
| Tips: |
|
If you previously referenced the internal value for a profile, use this list to determine the name to use instead:
| Standard Profile Name | $Profile Value |
|---|---|
| System Administrator |
PT1
|
| Standard User |
PT2
|
| Ready Only |
PT3
|
| Solution Manager |
PT4
|
| Marketing User |
PT5
|
| Contract Manager |
PT6
|
| Partner User |
PT7
|
| Standard Platform User |
PT8
|
| Standard Platform One App User |
PT9
|
| Customer Portal User |
PT13
|
| Customer Portal Manager |
PT14
|
$RecordType
| Description: | A global merge field to use when referencing the record type of the current record. |
| Use: | Add $RecordType manually to your s-control. |
| Visualforce Example: | To return the ID of the current record type, use this: |
| Tips: |
|
$Request
| Description: | A global merge field to use when referencing a query parameter by name that returns a value. |
| Use: | Add $Request manually to your s-control. |
| S-Control Example: | This snippet, named This s-control calls this snippet using
the |
| Tips: | Don’t use $Request in Visualforce pages to reference query parameters. Use $CurrentPage instead. |
$Resource
$SControl
$Setup
$Site
Note that only these site fields are available:
| Merge Field | Description |
|---|---|
| $Site.Name | Returns the API name of the current site. |
| $Site.Domain | Returns your Salesforce Sites based URL. |
| $Site.CustomWebAddress | Returns the request's custom URL if it doesn't end in
force.com or returns the site's primary
custom URL. If neither exist, then this returns an empty string.
Note that the URL's path is always the root, even if the request's
custom URL has a path prefix. If the current request isn't a site
request, then this field returns an empty string. This field's value
always ends with a / character.
Use of $Site.CustomWebAddress is discouraged, and we recommend using
$Site.BaseCustomUrl instead. |
| $Site.OriginalUrl | Returns the original URL for this page if it’s a
designated error page for the site; otherwise, returns null. |
| $Site.CurrentSiteUrl | Returns the base URL of the current site that references and
links should use. Note that this field might return the referring
page's URL instead of the current request's URL. This field's value
includes a path prefix and always ends with a / character. If the current request
isn't a site request, then this field returns an empty string. Use
of $Site.CurrentSiteUrl is discouraged. Use $Site.BaseUrl
instead. |
| $Site.LoginEnabled | Returns true if the current
site is associated with an active login-enabled portal; otherwise
returns false. |
| $Site.RegistrationEnabled | Returns true if the current
site is associated with an active self-registration-enabled Customer
Portal; otherwise returns false. |
| $Site.IsPasswordExpired | For authenticated users, returns true if the currently logged-in user's password is
expired. For non-authenticated users, returns false. |
| $Site.AdminEmailAddress | Returns an empty string. This merge field is deprecated. |
| $Site.Prefix | Returns the URL path prefix of the current site. For example, if
your site URL is
MyDomainName.my.salesforce-sites.com/partners,
/partners is the path prefix. Returns
null if the prefix
isn’t defined. If the current request isn't a site request,
then this field returns an empty string. |
| $Site.Template | Returns the template name associated with the current site; returns the default template if no template has been designated. |
| $Site.ErrorMessage | Returns an error message for the current page if it’s a designated error page for the site and an error exists; otherwise, returns an empty string. |
| $Site.ErrorDescription | Returns the error description for the current page if it’s a designated error page for the site and an error exists; otherwise, returns an empty string. |
| $Site.AnalyticsTrackingCode | The tracking code associated with your site. Services such as Google Analytics can use this code to track page request data for your site. |
| $Site.BaseCustomUrl | Returns a base URL for the current site that doesn’t use a
subdomain. The returned URL uses the same protocol (HTTP or HTTPS)
as the current request if at least one non-force.com custom URL that
supports HTTPS exists on the site. The returned value never ends
with a This field replaces CustomWebAddress and includes the custom URL's path prefix. |
| $Site.BaseInsecureUrl | This merge field is deprecated. Returns a base URL for the
current site that uses HTTP instead of HTTPS. The current request's
domain is used. The returned value includes the path prefix and
never ends with a / character.
If the current request isn't a site request, then this method
returns an empty string |
| $Site.BaseRequestUrl | Returns the base URL of the current site for the requested URL.
This isn't influenced by the referring page's URL. The returned URL
uses the same protocol (HTTP or HTTPS) as the current request. The
returned value includes the path prefix and never ends with a
/ character. If the current
request isn't a site request, then this method returns an empty
string. |
| $Site.BaseSecureUrl | Returns a base URL for the current site that uses HTTPS instead
of HTTP. The current request's domain is preferred if it supports
HTTPS. Domains that aren’t force.com subdomains are preferred over
force.com subdomains. A force.com subdomain, if associated with the
site, is used when no other HTTPS domains exist in the current site.
If there are no HTTPS custom URLs in the site, then this method
returns an empty string. The returned value includes the path prefix
and never ends with a /
character. If the current request isn't a site request, then this
method returns an empty string. |
| $Site.BaseUrl | Returns the base URL of the current site that references and
links should use. Note that this field may return the referring
page's URL instead of the current request's URL. This field's value
includes the path prefix and never ends with a This field replaces $Site.CurrentSiteUrl. |
| $Site.MasterLabel | Returns the value of the Master Label field for the current site. If the current request isn't a site request, then this field returns an empty string. |
| $Site.SiteId | Returns the ID of the current site. If the current request isn't a site request, then this field returns an empty string. |
| $Site.SiteType | Returns the API value of the Site Type field for the current site. If the current request isn't a site request, then this field returns an empty string. |
| $Site.SiteTypeLabel | Returns the value of the Site Type field's label for the current site. If the current request isn't a site request, then this field returns an empty string. |
$System.OriginDateTime
| Description: | A global merge field that represents the literal value of 1900-01-01 00:00:00. Use this global variable when performing date/time offset calculations, or to assign a literal value to a date/time field. |
| Use: |
|
| Formula Example: | This example illustrates how to convert a date field into a date/time field. It uses the date in the OriginDateTime merge field to get the number of days since a custom field called My Date Field. Then, it adds the number of days to the OriginDateTime value. OriginDateTime is in the GMT time zone but the result is displayed in the user’s local time zone. |
| Flow, Process, and Visualforce Example: | This example calculates the number of days that have passed since January 1, 1900: |
| Tips: | This global variable is available in:
|
$User
| Description: | A global merge field type to use when referencing information about the current user. User merge fields can reference information about the user such as alias, title, and ID. Most of the fields available on the User standard object are also available on $User. |
| Use: |
|
| Validation Rule Example: | This validation rule formula references the ID of the current user to determine if the current user is the owner of the record. .. Use an example like this to ensure that only the record owner or users with an administrator profile can make changes to a custom field called Personal Goal: |
| Flow Example: | Create a flow formula (Text) that has this expression. Once you create that formula, reference it anywhere that you need to call the user by name in your flow. By referencing the $User global variable, you avoid using a Get Records element, which counts against flow limits. |
| Visualforce Example: | This example displays the current user’s company name, as well as the status of the current user (which returns a Boolean value). |
| Tips: |
|
$User.UITheme and $User.UIThemeDisplayed
$UserRole
| Description: | A global merge field type to use when referencing information about the current user’s role. Role merge fields can reference information such as role name, description, and ID. |
| Use: |
|
| Validation Rule Example: | This validation rule formula references the user role name to validate that a custom field called Discount Percent doesn't exceed the maximum value allowed for that role: |
| Process, Flow, and Visualforce Example: | |
| Tips: |
You can’t use these
|

