Lightning Experience doesn't support the use of static URLs to link to Salesforce
resources. Fortunately, there's a much better alternative that future proofs your URLs. URLFOR is
a function that calculates a URL based on inputs, rather than relying on something static that
can't change. Use the URLFOR function with the appropriate action instead of direct
URLs.
Required Editions
| Available in: Group, Professional, Enterprise,
Performance, Unlimited, and Developer Editions
|
| User Permissions
Needed |
| To create, edit, or delete Visualforce pages: |
Customize Application |
Because static URLs can be applied in many ways, it’s not possible to cover all
possibilities. Let’s look at a case where a static URL is used to link to the edit page for
an account. Then you can use this example, including the code samples, as a guide for
addressing other static URLs in your pages.
-
Locate href and .Id} in the Visualforce code.
-
From Setup, enter Visualforce in the Quick
Find box, then select Visualforce Pages.
-
Click Edit next to the Visualforce
page.
-
Search the Visualforce markup for each of the following:
href and .Id}.
<apex:page standardController="Account" lightningStylesheets="true">
<apex:outputLink value="/{!Account.Id}/e" >Edit Account</apex:outputLink>
</apex:page>
-
Determine where the static URL is redirecting to. You can figure this out by testing
the Visualforce page in Salesforce Classic.
-
Find the appropriate URLFOR action to replace window.location.
-
Replace all static URLs with URLFOR functions.
<apex:page standardController="Account" lightningStylesheets="true">
<apex:outputLink value="{!URLFOR($Action.Account.Edit, Account.Id, null, true)}">Edit Account</apex:outputLink>
</apex:page>
-
Save your changes.