1

I want to display the standard Salesforce page after clicking on 'New' button for some conditions and for others I want to override the 'New' button with a VF page. I am not really sure what should be the correct approach to solve this tricky situation. Any suggestions will be really appreciated.

4
  • Found a blog on how to do it. Lemme know if that works for you. mrjavascript.blogspot.com/2013/07/…
    – Tim Hunter
    Commented Jul 23, 2020 at 20:21
  • 1
    Traditionally this is solved with an interstitial step, which is your button override, and that component (a VF page or an Aura component) would execute the logic to check your criteria on load and redirect to the standard page URL for the 'new' action with the parameter nooverride=1 in the URL, or it would redirect the user to the custom destination to create a new record.
    – Mark Pond
    Commented Jul 23, 2020 at 20:31
  • to expand on Mark's comment; you use an IF expression in the VF page's action= parameter with a NULL true result displays the VF markup and a false result does a URLFOR to the standard page with nooverride=1 param
    – cropredy
    Commented Jul 24, 2020 at 1:43
  • @cropredy , Thanks for the advice. Could you please guide me how to actually implement it in code? Let's say I want to Override the page with VF page when Country__c field on User object is CH and I want to display Standard page when Country__c field is AE?
    – Rahul
    Commented Jul 24, 2020 at 10:15

1 Answer 1

0

Here is a VF solution expanding on Mark's comment. The fourth argument to URLFOR is nooverride

<!-- Display markup when running user is Switzerland, otherwise, use standard page -->
<apex:page standardController="Foo__c" 
       action="{!IF($User.Country__c = 'CH',
                    NULL, 
                    URLFOR($Action.Foo__c.New,null,null,true)
                   )}"

   <apex:form>
     <!-- my override markup goes here -->
   </apex:form>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .