0

I've overridden the 'Edit' button on a custom record with a Visualforce page and now I can't change the record type. It'll let me go to the 'Change' screen, click continue, but then the record type has been changed back.

I have no code referencing the record type at all on the page, in the controller, or any classes and triggers. This is what my page header looks like. The createOrEdit variable is just a string for either $Action.SFDC_MDF__c.edit or $Action.SFDC_MDF__c.new depending on whether I find a Fund Request Id.

<apex:page action="{!if($Profile.Name =='Partner - Reseller' || $Profile.Name=='Partner - Distributor',
                null, 
                urlFor(createOrEdit, $ObjectType.SFDC_MDF__c,
                [retURL=returnURL,id=myMDF.Id], true))}" 
        showHeader="true" sidebar="true" standardController="SFDC_MDF__c" extensions="FundRequestExtension" docType="HTML-5.0" title="Fund Request">

This has to be a bug or I'm not seeing something? Is this simply something that we have to deal with as a consequence for overriding standard buttons?

I've tried querying the recordType in the controller's constructor and can verify that it isn't being updated prior to the redirect.

  • 1
    The change screen does not set the value, it simply get the selected value and passes it as a URL parameter. If you controller is updating the record and not grabbing the selected record type from the URL parameter then the new record type will never be applied to the record – Eric Nov 15 '15 at 6:26
  • Thanks, Eric. That did it. I just grabbed the URL parameter in the controller and set it in the page parameters of the URLfor in the page action. – Command-Z Nov 15 '15 at 8:18
2

The change screen does not set the value, it simply get the selected value and passes it as a URL parameter. If you controller is updating the record and not grabbing the selected record type from the URL parameter then the new record type will never be applied to the record

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.