I want to display the add product to opportunity price book page(/p/opp/SelectSearch) in lightning. We override the opportunity edit screen with VF and then redirect to this page:

        PageReference returnURL = new PageReference('/p/opp/SelectSearch');
        returnURL.getParameters().put('addTo', upsertedOpportunity.id);
        List<OpportunityLineItem> oppProducts = [Select ID , OpportunityId From OpportunityLineItem where id=:upsertedOpportunity.id];
        Id oppProductDetailPageID=null;
        if(oppProducts!=null && oppProducts.size()>0){
            oppProductDetailPageID = oppProducts[0].id;
            returnURL.getParameters().put('retURL', '/'+oppProductDetailPageID);

        //returnURL.getParameters().put('retURL', '/apex/SPW_OpportunityView'+upsertedOpportunity.id+'/nooverride=1');
        return returnURL;

If you are in lightning then it displays the vf styled as lightning but then after the redirect Salesforce switches to classic, then after you add a product it switches you back to lightning. Is there no way to keep this page in lightning?

enter image description here

I suspect lightning isn't supported because when you try to override the add product page there is no option for overriding with a lightning component:

enter image description here

ANY info would be greatly appreciated. Here is another post that almost exactly matches my problem.

  • <br /> As per the document link, I can see that there is an option to look at the page in the lightning experience once the lightning experience is enabled. To view, the page in lightning experience organization lightning experience must be enabled. Please tell me whether it is custom or standard page? – Rahul Apr 19 at 9:37
  • 1
    In Lightning experience, when click on Add product on Opportunity related list, it shows the dialog window. So basically url is not updated when clicked on Add Product button. I think you need to create lightning component to handle this use case. – daru badnaam Apr 19 at 10:27
  • thanks ! LEX is enabled in this org, When I redirect to the add product page it always switches from lightning to classic. – SallyRothroat Apr 19 at 15:11
  • Yea that works for me too, I can add products to an opportunity using lightning, but we have custom validation and need to be able to redirect to the lightning version of this page – SallyRothroat Apr 19 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.