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
Shane K 8Shane K 8 

Overwrite New button with Visualforce page

Hello,

Is it possible to achieve this functionality?

I would like to override the standard New button with visualforce page, which I know is possible, but based on some criteria I want to call a either a custom lightning component or the standard New button functionality. I will be using a controller to check my criteria but want to know how to use the standard New button functionality if the criteria does not meet. How to leverage the standard New button functionality?

Thanks.
ANUTEJANUTEJ (Salesforce Developers) 
Hi Shane,

By default there is a way to mention that in lightning you can use lightning component and in classic you can mention to use visual force page.

Does this help?

Also, I would suggest you to have a look at the below link that mentions a way to conditionally render in visualforce page.

>> https://help.salesforce.com/articleView?id=000324662&type=1&mode=1

I hope this helps and in case if this comes handy can you please choose this as best answer so that it can be useful for others in the future.


Regards,
Anutej
Abhishek BansalAbhishek Bansal
Hi Shane,

There is a detail tag in the apex which you can use in your VF page if you want to show the standrad layout. Please see the VF page code below:
<apex:page ...............>

	<apex:outputPanel rendered="{!showStandardPage}">
		<apex:detail/>
	</apex:outputPanel>
	
	<apex:outputPanel rendered="{!!showStandardPage}">
		....... show lightning component........
	</apex:outputPanel>
	
</apex:page>
Let me know if you have doubts .

Thanks,
Abhishek Bansal.
Kallu KaliaKallu Kalia
Nice