+ Start a Discussion
krishna chaitanya 35krishna chaitanya 35 

Need help in lightning how to override standard new page in opportunity with visualforce page

Hi All,

I have an requirement to override standard salesforce page with visualforce page in "New" button for opportunity ,it is working in salesforce classic as expected but the same is not working in lightning experience.can any one help me on this how to re-direct in lightning salesforce.
My code:
<apex:page standardController="Opportunity" extensions="MyController" action="{!redirect}"> </apex:page>

public with sharing class MyController{

    public MyController(ApexPages.StandardController controller) {


    public PageReference redirect() {
           PageReference pr = new PageReference('/006/e');
            pr.getParameters().put('opp3', 'Name_Opco_Product');
           return pr;

Thanks in advance,
SandhyaSandhya (Salesforce Developers) 
krishna chaitanya 35krishna chaitanya 35
Hi Sandhya,

Thank you for the links.But in the links i didnt find any example or sample code for over riding the standard pages.If you have any sample reference please provide me.

Hello Krishna,

To use the override standard button with the Visualforce page in the Lightning experience. You have to check which user interface is running currently. Below is sample code.
<apex:page standardController = "Opportunity">
<apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme3'  || $User.UIThemeDisplayed == 'Theme4d' }">
    <apex:outputText value="This is Salesforce Classic."/>
   <apex:outputText value="This is Lightning Experience."/>
    <apex:outputText value="These are multiple components wrapped by an outputPanel."/>
This page will work in both Salesforce Classic as well as Lightning Experience user interface.

Hope this will help you as well as others who are looking for the same.

Arun Kumar