URLFOR() explained - El Toro - Find articles about Visualforce, Apex, Force.com and Salesforce in general

Print Preview

URLFOR() explained

This is a very useful function in Salesforce.com, both to include static resources and as actions for action tags.

URLFOR function returns a relative URL using this syntax:

URLFOR(target, id, [inputs], [no override])

This table describes the parameters used:

Target:Action, s-control or static resource.
Id:Resource name (string type) or record ID (depends on the “target”).
Inputs:Additional parameters passed. Format: [param1="value1", param2="value2"]
no override:A Boolean flag. Set to true if to display a standard Salesforce page regardless of whether you have defined an override for it elsewhere. (default false)

Examples:

Files and folders:

Resource file:URLFOR($Resource.LogoImg)
Resource file in ZIP folder:URLFOR($Resource.CorpZip, 'images/logo.gif')
Note: The path to the file is case sensitive

Actions shared among all objects:

View record: URLFOR($Action.Account.View, account.id)
Create new record: URLFOR($Action.Account.New)
Edit record: URLFOR($Action.Account.Edit, account.id)
Delete record: URLFOR($Action.Account.Delete, account.id)
List view: URLFOR($Action.Account.Tab, $ObjectType.Account)

Note: Some objects support other additional actions, for example Case supports "CloseCase" action. To know which action can be used, check the buttons and links which can be overridden for an object (as shown on the next image), just use the name of the function like this: URLFOR($Action.Object.Name, …)

comments powered by Disqus

© El Toro . IT @ 2013
Andrés Pérez