We are migrating a section of the company to Lightning. We have some objects whose records open in custom Visualforce pages because we wanted to display information across multiple tabs. We achieved this by overriding the Standard View button to redirect to custom Visualforce page.

Now, the problem is that for our SF Classic users this button (URL) should still redirect to the old custom VF page, but our Lightning users need to be redirected to the standard record page (i.e. - default button behavior). Is there any way to achieve this?

enter image description here

  • You can try using nooverride=1 parameter to avoid navigation in lightning. URL: I use /one/one.app#/sObject/{recordId}/edit?nooverride=1
    – Raul
    Oct 18, 2017 at 11:42

2 Answers 2


You could redirect with action attribute of apex:page tag based on contextfrom $User.UITheme and add nooverride=1 parameter when page is running in Lightning:

Here is an example, tested it, seems to be working. Would be awesome to generate the URL dynamically instead of hardcoding.

<apex:page standardController="Contact" 
    action="{!(IF($User.UITheme == 'Theme3', 
        URLFOR('/one/one.app#/sObject/' +Contact.Id+ '/view?nooverride=1')
    <!-- your page code continues -->

You need to use UserInfo.UIThemeDisplayed() to identify if your user is in classic view or in Lightning Experience.

On your page's action attribute call a controller method and in the method check if current user is in Lightning then redirect them to standard page else they will be redirect back to custom VF page.

public pagereference prrediect() {
    if(UserInfo.getUiThemeDisplayed() == 'Theme4d')
        return new pagereference('/one/one.app#/sObject/'+recordId+'?nooverride=1'); //you can change this URL

   return null;

Introducing UI Theme Detection for Lightning Experience

  • 1
    Thank you for your answers. I gave you both an upvote, but I decided to accept @RahulSharma answer since he made the first comment on my post, I hope you won't hold it against me. I also used his approach, but this approach works as well, I tested it.
    – smukov
    Oct 18, 2017 at 12:21
  • @smukov no issue mate. But I don't understand WHY someone down voted this answer. Oct 18, 2017 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .