function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aviv GabayAviv Gabay 

Creating a generic Visualforce page to load both classic pages and Lightning pages

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?
NagendraNagendra (Salesforce Developers) 
Hi Gabay,

Sorry for this issue you are encountering.

May I suggest you please check below link from the stack exchange community with a similar discussion which might help you further. Please let us know if this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
mukesh guptamukesh gupta
Hi,

Please follow below url to achive your goal:-

https://trailhead.salesforce.com/en/modules/lex_dev_visualforce/units/lex_dev_visualforce_multipurpose_pages

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Aviv GabayAviv Gabay
Hi guys thanks for answering, the tutorials you mentioned teach how to build a page that works both for LEX and Classic, but this was not my question. My question is how can I include an existing standard page using a Visualforce "View" Override and make it work seamlessly on both Classic and Lightning themes.