You are here:
URLFOR
Returns a URL for an action, an s-control, a Visualforce page, or a file in a static resource archive. URLFOR is available for use in custom buttons and links, s-controls, and Visualforce pages.
Use
{!URLFOR(target, [id],
[inputs], [no override])} and replace
target with the URL or action, s-control, or static resource merge variable;
id with an optional reference to the record; and inputs
with any optional parameters. The no override argument is also optional and
defaults to false. It applies to targets for standard
Salesforce pages such as $Action.Account.New. Replace
no override with true when you want to
display a standard Salesforce page regardless of whether you have defined an override for it
elsewhere.
The input values can be dynamic. For example, to include an account ID, specify:
{!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])}The resulting URL includes a parameter with the ID, such as:
https://MyDomainName--PackageName.vf.force.com/apex/myVisualforcePage?accountId=001B0000002txolYou can also use non-string variables, like an SObject variable. For example, if you supply
[myAccountParam=Account], the value is converted to a
string, and the URL contains ?MyAccountParam=001B0000002txol. You can also use a parameter to supply a static
value, such as [param1=55].
[myVariable="value"] and set
myVariable to "param1", the resulting URL includes ?myVariable=value1 and not the param1
value.Tips
- Use global variables to access special merge fields for actions, s-controls, and static resources.
- If an input parameter name begins with any character other than a letter or dollar sign ($), enclose it in quotation marks.
- Enclose multiple inputs in brackets to indicate they are
together:
{!URLFOR($Action.Case.View, Case.Id, [param1="A", param2="B"])} - Set inputs to
nullif you don’t have any inputs to pass, but you want to set the no override argument:{!URLFOR($Action.Case.View, Case.Id, null, true)} - When you override a standard action, that action is no longer available in Salesforce. For example, if you override the new account action, that affects the New button on all pages, such as the account detail page, account related lists on other detail pages, and the Create New dropdown list in the sidebar. To override a standard action but still access it, use the no override argument in your s-control to reference that action.
- When you override the tab home page for a standard or custom tab, use the tab’s
$Action global variable as the target value, and the
tab’s object type for the id value. For example,
URLFOR($Action.Account.Tab, $ObjectType.Account).
force.com domain or a site domain. URLFOR
currently returns an absolute URL for all Visualforce pages. See Ensure Access to Your Visualforce Pages in Summer ’24 and Winter
’25.<apex:image url="{!URLFOR($Resource.TestZip, 'images/Bluehills.jpg')}"
width="50" height="50"/>
In this example, the <apex:image> component references
a .jpg file contained within a .zip file that has been uploaded as a static resource. When
uploaded, the name of the static resource was defined as TestZip, and the path to the image within the resource is images/Bluehills.jpg.

