• Aviv Gabay
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I'm trying to override View action of a Standard Object (Opportunity in this case) with a Visualforce page. My override works on both Classic and Lightning theme. However, on lightning pages, my Visualforce page changes the original page's layout.

My Visualforce Page:
<apex:page standardController="Opportunity" lightningStylesheets="true">
<apex:detail subject="{!Opportunity.Id}" relatedList="true" title="true" rendered="true" />
</apex:page>

It works perfectly on the Classic theme, but here is how it looks on Lightning compared to the original Opportunity page without override:
User-added image

How do I achieve the functionality of creating a generic Visualforce page to load both classic pages and lightning pages?
And if it's not possible, what are the alternatives to achieve it?
I'm trying to replace the view of a standard page with my custom VF page.
This works great on the classic theme but not on the lightning theme and mobile application.

 - In the VFP I checked "Available for Lightning Experience, Lightning
   Communities, and the mobile app".

[![enter image description here][1]][1]

 - In the view override, I checked "Use the Salesforce Classic
   override".

[![enter image description here][2]][2]

Visualforce page (I don't think it has something to do with the page itself, it doesn't work with any page):

    <apex:page standardController="Opportunity" lightningStylesheets="true">
        <apex:detail subject="{!Opportunity.Id}" relatedList="true" title="true" rendered="{!Opportunity.Amount < 10}" />
        <apex:pageBlock rendered="{!Opportunity.Amount > 10}">
            <apex:pageBlockSection columns="1">
                <apex:pageMessage summary="Amount is less than 10" severity="warning" strength="3" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:page>

I think that the problem is that for some reason the override doesn't even get fired on lightning experience. In the classic, I can see the URL changing to an APEX page, but on the lightning, it doesn't even bother trying to change the URL

 - **URL in classic view (successful redirection):**

`https://c.eu16.visual.force.com/apex/xxx`

 - **URL in lightning (doesn't redirect):**

`https://eu16.lightning.force.com/lightning/r/Opportunity/0061t000001uPaDAAU/view`



**EDIT:**

Although I really don't like this option, I tried creating a lightning component using the following code:

    <aura:component implements="flexipage:availableForAllPageTypes" access="global" >
        <aura:attribute name="greeting" type="String" default="Hello" access="global" />
        <aura:attribute name="subject" type="String" default="World" access="global" />
    
        <div style="box">
          <span class="greeting">{!v.greeting}</span>, {!v.subject}!
        </div>
    </aura:component>

and changed the view override to the created component. I couldn't get it working that way too.


  [1]: https://i.stack.imgur.com/jwBpF.png
  [2]: https://i.stack.imgur.com/MhjzR.png
I'm trying to override View action of a Standard Object (Opportunity in this case) with a Visualforce page. My override works on both Classic and Lightning theme. However, on lightning pages, my Visualforce page changes the original page's layout.

My Visualforce Page:
<apex:page standardController="Opportunity" lightningStylesheets="true">
<apex:detail subject="{!Opportunity.Id}" relatedList="true" title="true" rendered="true" />
</apex:page>

It works perfectly on the Classic theme, but here is how it looks on Lightning compared to the original Opportunity page without override:
User-added image

How do I achieve the functionality of creating a generic Visualforce page to load both classic pages and lightning pages?
And if it's not possible, what are the alternatives to achieve it?
I'm trying to replace the view of a standard page with my custom VF page.
This works great on the classic theme but not on the lightning theme and mobile application.

 - In the VFP I checked "Available for Lightning Experience, Lightning
   Communities, and the mobile app".

[![enter image description here][1]][1]

 - In the view override, I checked "Use the Salesforce Classic
   override".

[![enter image description here][2]][2]

Visualforce page (I don't think it has something to do with the page itself, it doesn't work with any page):

    <apex:page standardController="Opportunity" lightningStylesheets="true">
        <apex:detail subject="{!Opportunity.Id}" relatedList="true" title="true" rendered="{!Opportunity.Amount < 10}" />
        <apex:pageBlock rendered="{!Opportunity.Amount > 10}">
            <apex:pageBlockSection columns="1">
                <apex:pageMessage summary="Amount is less than 10" severity="warning" strength="3" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:page>

I think that the problem is that for some reason the override doesn't even get fired on lightning experience. In the classic, I can see the URL changing to an APEX page, but on the lightning, it doesn't even bother trying to change the URL

 - **URL in classic view (successful redirection):**

`https://c.eu16.visual.force.com/apex/xxx`

 - **URL in lightning (doesn't redirect):**

`https://eu16.lightning.force.com/lightning/r/Opportunity/0061t000001uPaDAAU/view`



**EDIT:**

Although I really don't like this option, I tried creating a lightning component using the following code:

    <aura:component implements="flexipage:availableForAllPageTypes" access="global" >
        <aura:attribute name="greeting" type="String" default="Hello" access="global" />
        <aura:attribute name="subject" type="String" default="World" access="global" />
    
        <div style="box">
          <span class="greeting">{!v.greeting}</span>, {!v.subject}!
        </div>
    </aura:component>

and changed the view override to the created component. I couldn't get it working that way too.


  [1]: https://i.stack.imgur.com/jwBpF.png
  [2]: https://i.stack.imgur.com/MhjzR.png