Welcome to SFDC Share Point

Salesforce Blogs

Welcome to SFDC Share Point

Salesforce Blogs

How to check Person Account are enabled using Apex?

Some time it is needed to check whether this org has person account enabled or not.

There are couple of ways we can think of,

  1. Using Describe Call

boolean isPersonAccount = Schema.SObjectType.Account.fields.getMap().containsKey('isPersonAccount');

– Describe Call count against Governor limits.

  1. Accessing field of Account (“isPersonAccount”)

boolean isPersonAccount = false;
	Sobject accSo = new Account();

	//If this field Exists then there is Person Account Enabled in this Org. Else you will get Exception
	isPersonAccount = true;

} catch(Exception e) {
	isPersonAccount = false;


In this method exception getting generated if that field doesn’t Exist.