What is URL Hacks ?
The technique of reverse engineering standard salesforce URL & using them to build a custom solution.Problems of using URL Hacks ?
The standard salesforce URL formats & parameters is undocumented. So, it could be changed anytime during standard release or during bug fixes. So, it's better to avoid
How to avoid it ?
Salesforce provides standard ways to access the URL & parameters in Visualforce & Apex. Developers must use them instead of hardcoding the URL's in the code.Where is the code ?
Instead of using something like '/006/o' to redirect to opportunity tab page, one could use $Action.Opportunity.Tab with the help of URLFOR function to get the URL.For illustration, i have shown how to get the URL's for create, view, edit delete for an opportunity record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity"> | |
What would you like to do with this Opportunity - {!Opportunity.Name} | |
<apex:panelGrid columns="1"> | |
<!-- create --> | |
<apex:outputLink value="{!URLFOR($Action.Opportunity.New)}">Create New</apex:outputLink> | |
<!-- view --> | |
<apex:outputLink value="{!URLFOR($Action.Opportunity.View, Opportunity.Id)}">View</apex:outputLink> | |
<!-- edit --> | |
<apex:outputLink value="{!URLFOR($Action.Opportunity.Edit, Opportunity.Id)}">Edit</apex:outputLink> | |
<!-- delete --> | |
<apex:outputLink value="{!URLFOR($Action.Opportunity.Delete, Opportunity.Id)}">Delete</apex:outputLink> | |
</apex:panelGrid> | |
</apex:page> |
Where can i find more information ?
For more information, you can see the possible action values for all sObjects,$Action - Salesforce doc
Invalid parameter for function URLFOR
ReplyDeleteError is in expression '{!URLFOR($Action.Opportunity.View, Opportunity.Id)}' in component
this error occur in this visualforce page.
what is syntax of URLFOR and how to fatch Opportunity.Id. Which record is view