I'm trying to check if Person Account is enabled to read from 2 different fields conditionally.


IF (PersonAccountEnabled, field1,field2)

There seems no easy way to do this as, It seems there is no Org variable available for it.

We could use Account.IsPersonAccount but since it's a managed package the field may not exist in some org. and would end up in error if used.

Is there a workaround to read this Org. setting in a formula field.

Appreciate any thoughts. Thanks.

2 Answers 2


You can try some hack here. Create a hierarchical custom setting with a checkbox field. Now write a post install script which will check if org has Person Account available. If you found PA then set this checkbox to true.

Now you can use this checkbox field in your formula.

// Check to see if person accounts are enabled.
public Boolean personAccountsEnabled()
    // Describe the Account object to get a map of all fields
    // then check to see if the map contains the field 'isPersonAccount'
    return Schema.sObjectType.Account.fields.getMap().containsKey( 'isPersonAccount' );

You can't do that.

What you can do however (without writing Apex) is add a new hierarchical Custom Setting to your package that has a Boolean option like "Use Person Accounts". If that's enabled, you read from field1, otherwise from field2.

It would not be completely dynamic, since it would require an admin to enable it once but since person accounts are not toggled on/off it might suffice.

The formula would then be something like:

IF( $Setup.YOUR_NS__YourCustomSettingsName__c.YOUR_NS__UsePersonAccounts__c , field1, field2)

Whereas YOUR_NS is your package's namespace and YourCustomSettingsName__c is your custom setting's API name.

You must log in to answer this question.

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