What if instead of redirecting to a custom VF page that uses apex:detail, you redirect to a URL that suppressed the VF override and shows the default view page?
That's what I did for my case object: My new/view/edit buttons all redirect to a 'Redirect' VF page that does nothing but call an extension method that determines whether to show a VF page or suppress the VF override.
Here is the 'redirect' vf page:
<apex:page standardController="Case" extensions="CaseUniversalControllerExtension" action="{!pageRedirect}">
</apex:page>
The pageRedirect()
method that VF page is referencing has the following bits of relevant code:
map<string, string> pageParameters = ApexPages.currentPage().getParameters();
//uses info from SF URL to determine which button was clicked
if(pageParameters.get('Id') == null) detectedMode = 'New';
else if(pageParameters.get('Id') != null && pageParameters.get('retURL') != null) detectedMode = 'Edit';
else if(pageParameters.get('Id') != null && pageParameters.get('retURL') == null) detectedMode = 'View';
With the 'mode' determined (view/new/edit), you can determine which VF page you want to redirect to, or you can choose to suppress the VF page and show the default:
here is redirecting to another VF page:
if(detectedMode == 'New') return new PageReference('/apex/CasePortalUserEdit');
else if(detectedMode == 'Edit') return new PageReference('/apex/CasePortalUserEdit?id='+pageParameters.get('Id') + '&retURL=/' + pageParameters.get('Id'));
else if(detectedMode == 'View') return new PageReference('/apex/CasePortalUserView?id='+pageParameters.get('Id') + '&retURL=/' + pageParameters.get('Id'));
and here is suppressing the VF page:
if(detectedMode == 'New') return new PageReference('/500/e?ent=Case&nooverride=1&RecordType='+recordTypeID+'&retURL=/500/o');
else if(detectedMode == 'Edit') return new PageReference('/' + pageParameters.get('Id') + '/e?nooverride=1&RecordType='+recordTypeID+'&retURL=/' + pageParameters.get('Id'));
else if(detectedMode == 'View') return new PageReference('/' +pageParameters.get('Id') + '?nooverride=1');
the key parameter for suppressing a VF page is NoOverride=1
As far as I know, your best bet here is still to use Visualforce
and just surface lightning through that page.
<apex:page standardController="ChildObject__c" recordSetVar="children">
<!-- include lightning here -->
</apex:page>
Best Answer
By Default, You can override the lightning Interface button with Vf Page and Lightning Component. If you have flow and want to override the button with a flow:-