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
mkdjnsmkdjns 

Visualforce page causing validation error on Person Accounts

I have the following VF page that is called by a button on a Person Account record.

 

 

<apex:page standardController="Account" title="Cancel Account">
    <apex:sectionHeader title="Cancel Account"/>
    <apex:form id="theForm">
        <apex:pageBlock id="theBlock">
            <apex:pageBlockSection id="sectionOne">
                <apex:outputField value="{!Account.Name}" />
                <!-- Bound to Date Field -->                
                <apex:inputField value="{!Account.Account_Cancel_Eff_Date__c}" />
                <!-- Bound to Picklist -->
                <apex:inputField value="{!Account.Account_Cancel_Reason__c}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

When the page is called for a person account, Salesforce returns:

 

Validation Errors While Saving Record(s)

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Record Type ID: value not valid for the entity: Account". 

When the page is called for a normal Account, it renders as expected. If I remove the inputField that is bound to the picklist, then call the page for a person account, everything works as expected. What's going on here?

 

Jon Mountjoy_Jon Mountjoy_

Are you passing in a valid ID when you view the page?

 

ie. is it

 

http://naXYZ.salesforce.com/apex/myamazingpage?id=VALIDID

 

?

 

 

mkdjnsmkdjns

I am. The page is called from a button on the acount detail page. If I call the page without the problem field in the VF markup, things work fine. If I then edit the VF in Eclipse, save, then refresh my browser (which maintins the same URL which was working in the previous step) I get the error.

Pradeep_NavatarPradeep_Navatar

As the Error message is showing that custom validation error(s) So I think  the values in Account_Cancel_Reason__c picklist are depended on record type so It may happen that the Id you are giving is not match the Record Type and Picklist values.

mkdjnsmkdjns

Pradeep-

 

The Person Account record types have the same values available for Account_Cancel_Reason__c as any other account record type. Your suggestion doesn't help me resolve the issue either.

 

Anyone else know what might be causing this?

MattWelchMattWelch

Has anyone gotten this resolved. I've seen a few other posts about this in other threads, but no resolution. If I take the custom picklist associated with the Person Account off the VF page, everything works fine.

mkdjnsmkdjns

I haven't been able to sort it out yet. I do have an open ticket with Salesforce support, but so far it hasn't gone anywhere.

JDevJDev

This is clearly an SF bug and still outstanding after Spring 11. We have a simple VF page as a custom extension of Account in an org where all accounts are personAccounts. When testing the page we got this error, even when all the fields on the page were outputfields and there were no updates actions or input fields. After changing all the Account outputfields on the page from outputfields to outputText the problem was resolved. We'll also log this as a bug.

JDevJDev

Just to clarify we only see the problem on picklist fields on Account (whether custom or standard) and it happens with Person Accounts that have no validation rule issues (if edited and saved without changes), so the problem does not appear to be with the data or the code but rather with the OutputField as opposed to OutputText rendering of the picklist value.

mkdjnsmkdjns

i suspect that you are right about the bug. I'm still persuing my case with suport and will post here whan I know more.

mkdjnsmkdjns

I've finally gotten confirmation from suport that this is a bug. No word on when a fix will be issued.

mkdjnsmkdjns

With no fix forthcoming, I've rolled my own picklist solution per this article: 

 

http://blog.sforce.com/sforce/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html

 

Of course this is exactly what I was hoping to avoid doing since that's what apex:inputfield is for, but at least I'm rolling now...

dfiredfire

I couldn't get that to work for me. We had the same problem and I just used <apex:selectlist><apex:selectoptions> and created the lists in the controller. Not very elegant I know, but our picklists don't change so much and I didn't want to write SOQL to get every picklist we needed because of govenor limits concerns.

MinGyoonMinGyoon

OMG,

It makes me really crazy...


In case of using dependant picklist, can not use the FieldDescribeResult.


Also, hardcoding the selectList is not match my goal becuase my customer want to add or remove the picklist item significantly.


Does anyone who let me know about get the Dependnat Picklist values by controlling field?


Thanks,

MinGyoon

Seb OrtizSeb Ortiz

We're having the same bug using inputField for a custom Person Account picklist field.

Did you get any updates from SF support? Hope they take this under consideration asap

 

Regards

 

shruthishruthi

I fixed it using <apex:selectList> and getDescribe(); Check out the link below:

http://salesforce-shruthi.blogspot.com/2011/09/multiselect-picklist-solution-for.html

 

Hope this helps!

wgouldingwgoulding

I came across the issue recently, the way I was able to fix it was to include the field IsPersonAccount in your SOQL query, that way the controller knows that the record you are working with is a Person Account and will know that a Person Account Record Type can be applied to it. Otherwise it will throw an error.

Timothy KeithTimothy Keith
@wgoulding How do you add the "IsPersonAccount" feild in the SOQL query? 

Sorry, just an admin not a developer.