1

I have a custom object with two record types. I've written a Visualforce page to override the Clone button on the object. However I only really want to override for one record type (PCS). My solution was to use the action attribute in the apex:page tag, with a boolean which is set to true if the record type is PCS and false otherwise.

When I manually typed out the URL with the id param set, I got the page to behave as I would like. However after testing this, I overrode the Clone button with the VF page. When accessed from the Clone button it still works fine for PCS record types, but for other record types the page is stuck in some loop where the CONFIRMATIONTOKEN param keeps changing but no page is loaded. I'm using Chrome 57 if it makes a difference.

Here is a portion of the VF page:

<apex:page standardController="Consumable_Analysis__c" extensions="AnalysisClonerHelper" action="{!IF(pcs,null,URLFOR($Action.Consumable_Analysis__c.Clone,Id,[retURL=Id]))}" >
  ... //the rest of the page
</apex:page>
2

You need to override the override. Pass "true" for the optional fourth parameter:

<apex:page standardController="Consumable_Analysis__c" extensions="AnalysisClonerHelper" 
action="{!IF(pcs,null,URLFOR($Action.Consumable_Analysis__c.Clone,Id,[retURL=Id],true))}" >
  • Perfect, thank you! What is this doing exactly? Is it because $Action.Consumable_Analysis__c.Clone is calling the VF page now that I've overridden it? – Josh D May 2 '17 at 13:53
  • 1
    @JoshD Yes, the infinite loop was because of a redirect on the standard clone action, so the fourth parameter tells salesforce to override the override (thus, perform the default behavior). – sfdcfox May 2 '17 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.