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
nellymnjnellymnj 

Error in VisualForce page- person account custom field problem

Hello.
I've build a VisualForce page based on custom controller. Custom controller has 2 public getter method; both methods return list of accounts: Lapsed Members and Inactive Members. Account is set up as person account and I want to show 2 contact custom field on a page: Membership_Type__pc and Membership_Status__pc.
Here is  the page code:
<apex:page controller="ResetMember" tabStyle="Account">
  <apex:pageBlock title="Accounts with incorrect membership status"> 
          <apex:pageBlockTable value="{!lpsAccounts}" var="item">
          <apex:facet name="header">Lapsed Accounts</apex:facet>
          <apex:column value="{!item.name}"></apex:column>
          <!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
          <apex:column headerValue="Membership Status">
              <apex:outputText>Active Member</apex:outputText>
          </apex:column>
      </apex:pageBlockTable> 
      </apex:form>      
  </apex:pageBlock>
</apex:page>
 
As soon as i uncomment the line:
<!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
the page displays an error:
Invalid field Membership_Type__c for SObject Account
Is there a known problem with person account custom field in VisualForce or I am doing somthing wrong?
 
Thank you very much for any input
nellymnjnellymnj
No, it should be Membership_Type__pc, beacause this is really Contact custom field (custom Contact field for Person Account).
The field name is correct, in fact if I write it as Membership_Type__c the controller returns an error because the field does not exists (controller works fine in case Membership_Type__pc but the page returns an error), I also use the same field in a trigger that works on production site.
thank you for looking into that.

dchasmandchasman
This looks like an issue with the interaction between <apex:column value> attribute (makes column behave like apex:outputField) and PersonAccounts (a bug that we'll look into) - as a workaround try changing your apex:column to look like this:

Code:
<apex:column>
{!item.Membership_Type__pc}
</apex:column>

 



nellymnjnellymnj

Thank you Doug, but no, this did not - still getting the same error:

Invalid field Membership_Type__c for SObject Account

dchasmandchasman
Yes - I tried it here also and found the same thing. All is not lost though - with a little bit of Apex Code we can work around this until my team can get a fix for the underlying issue. The basic idea of the workaround is to create a simple apex class that wraps the sobject and provides indirect access via a property that can access the field via apex code that we're having trouble binding to directly. Something like this:

Code:
public class PersonAccountWrapper {
public PersonAccountWrapper(Account account) {
this.account = account;
}

public Account account { get; private set; }

public String getMembershipType() { return account.Membership_Type__pc; }
}

 



Message Edited by dchasman on 06-27-2008 12:58 PM
nellymnjnellymnj
Thank you very much Doug, I'll try that
StephenBStephenB

Hi Doug - are custom person account fields in Sites still a problem? I have tried to put a custom person account field on a Visualforce page (eg. Preferred_Contact_Method__pc). In standard salesforce.com I can see and interact with this field no problem on the VF page. In Sites however, the custom person account field isn't displayed (for existing data) or isn't editable for new data.

 

Is it worth raising a case for this?

 

Thanks,

Stephen