Behold Yourself – Summer 17 is here to break legacy Visualforce Navigation code in Lightning Experience

In Summer 17, URLFOR method in Visualforce would not work in Lightning Experience if used directly. Even API is not fully compatible.

Salesforce Summer 17 Logo

You read it right. Its not Locker Service that may break your code, but Summer 17. If you have legacy Visualforce page, which needs to navigate to Lightning experience and URLFOR is used directly, then chances of getting below error are very high.

Salesforce Summer 17 - URLFOR Not working
Salesforce Summer 17 – URLFOR Not working

In above screenshot, I got MALFORMED_ID : malformed Id error in one of my Visualforce, where I needed to navigate to new Account record.

Steps to reproduce error

Create below Visualforce in Summer 17, where Lightning experience is enabled.


  <apex:page standardController="Account">
 Redirect Using URLFOR : <a href="{!URLFOR($Action.Account.New, null, [retURL='/001',nooverride='1'], true)}">
 URLFOR - Not working in Summer 17 Lightning Experience </a> <br /><br />
 Simple Redirect : <a href="/001/e?retURL=%2F001%2Fo&nooverride=1">Direct - Not working in Summer 17 Experience</a> <br /><br />

 Working Example : <a href="javascript:createAccount()">Working with Summer 17 Experience</a> 
 <script type="text/javascript">
 function createAccount(){
 if( (typeof sforce != 'undefined') && sforce && (!! ) {'Account',null,{'retURL':'/001','nooverride':'1'});
 window.location='{!URLFOR($Action.Account.New, null, [retURL='/001',nooverride='1'], true)}';

Next step is to override New button of Account by above Visualforce page.

After this setup, if we try to create New Account, below page will appear.

Override New button in Salesforce Lightning Experience
Override New button in Salesforce Lightning Experience

In above code, if we click first two URL, we will get an error. However, third URL will work.

Key take away in this post is that, we need to use object, which will be available by default in Lightning experience.

Problem in above code and API:

Above code will not be redirected properly on cancel button. so we can say even is not full proof. In that scenario, we can use below snippet. Notice how URL is used here

var simpleURL = '/one/' ; 

Its too early to party 🙁 . Above code will work only in Summer 17 but not in previous release.

I was not able to find solution which will work in Summer 17 as well as in Spring 17. Please drop a comment if you know the answer else we have to live with this code, as anyways all instances would be moved to Summer 17 in few weeks.

Below Video shows the issue and its fix discussed in this post.

Resources :

  1. Trailhead – Manage Navigation in Lightning experience 
  2. force:createRecord – Lightning Component developer guide

Related posts

6 thoughts on “Behold Yourself – Summer 17 is here to break legacy Visualforce Navigation code in Lightning Experience”

  1. HI Jitendra,

    I believe the problem with hard-coded URLs on lightning experience especially when trying to open a create new record screen is that if the object has record type defined then the record type selection screen is not shown and the user is taken directly to the add new record screen and when they press save, salesforce gives an error that record type id cannot be null (or something like that).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.