Salesforce

Global Variables on Visualforce pages

$Resource

Use the $Resource variable to reference static resources.

<img src="{!$Resource.myImage}" />

Can be used in conjunction with the URLFOR function to reference files inside of a zipped static resource:

<apex:includeScript value="{!URLFOR($Resource.myResources, 'js/app.js')}" />

$Label

The $Label variable can be used to display text defined in your custom labels.

<apex:outputText value="{!$Label.Welcome_Message}" />

You can do formatting with labels as well. Suppose you have a custom label named Welcome_Message defined as

Welcome to our site, {0}!

You could use the label to display a formatted message:

<apex:outputText value="{!$Label.Welcome_Message}" rendered="{!NOT(ISBLANK($User.ContactId))}">
  <apex:param value="{!$User.Contact.FirstName}" />
</apex:outputText>

## $User
The `$User` variable gives you access to all the standard and custom fields on the `User` object for the currently logged in user.

You are logged in as a user from {!$User.CompanyName}.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow