Activity Forums Salesforce® Discussions What Are Global Variables Explain With Examples?

  • shariq

    Member
    September 20, 2018 at 3:12 pm

    Hi,

    Global variables are the variables used to reference the general information about the current user or your organization on a page.

    Example:

    Global variables must be referenced using Visualforce expression syntax to be evaluated, for example, {!$User.Name}.

    List of available global variables are as below:

    1.     $Action
    2.     $Api
    3.     $Component
    4.     $ComponentLabel
    5.     $CurrentPage
    6.     $Label
    7.     $Label.Site
    8.     $ObjectType
    9.     $Organization
    10.  $Page
    11.  $Profile
    12.  $Resource
    13.  $SControl
    14.  $Setup
    15.  $Site
    16.  $User
    17.  $UserRole
    18.  $System.OriginDateTime
    19.  $ User.UITheme and $User.UIThemeDisplayed

    Thanks

  • Parul

    Member
    September 20, 2018 at 6:23 pm

    Adding some points:

    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.

     

    Thanks

  • shariq

    Member
    September 20, 2018 at 10:32 pm

    Hi,

    On vf page For example -

    {!Api.Session_ID} - It gives the salesforceUI session id.

    Hope this helps

     

  • Parul

    Member
    September 21, 2018 at 3:23 am

    Refer this ex:

    <apex:page controller="RecentlyViewedController">
    <apex:pageBlock>

    <apex:pageBlockTable data="{!RecentlyViewed}" var="rv">
    <apex:column headerValue="{!$ObjectType.RecentlyViewed.fields.Name.Label}">
    <apex:outputLink value="{!URLFOR($Action[rv.Type].View,rv.Id)}">
    <apex:outputText value="{!rv.Name}" />
    </apex:outputLink>
    </apex:column>
    </apex:pageBlockTable>

    </apex:pageBlock>
    </apex:page>

     

Log In to reply.

Popular Salesforce Blogs