Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can we use describeSObject to get the fields from a Person Account?

Normally we would use the following to get the fields from an Object:

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); 
Map<String, Schema.SObjectField> fieldMap = schemaMap.get('Account').getDescribe().fields.getMap();

How can we distinguish Person Account Fields from Business Account Fields?

share|improve this question
//To get a map of all fields an object
Map<String, Schema.SObjectField> M =Schema.SObjectType.Account.fields.getMap();
 //Boolean flag to detect person account enabled or not
  Boolean isPersonAccountEnabled=M.containsKey('IsPersonAccount');
  //Debug Statements
   System.debug('MAP DEBUG'+M);
  System.debug('PERSON ACCOUNT ENABLED'+isPersonAccountEnabled);

You are on target.If person Account enabled you will be able to get all fields also the isPersonAccount will be true .

Person Account fields ends with __pc while normal Account fields ends in __c.

share|improve this answer
Just added a follow-up question on how we can distinguish Business Account fields and Person Account fields – Joey Chan Feb 14 '13 at 16:59
updated the answer buddy! – Mohith Shrivastava Feb 14 '13 at 17:23

You can definitely get Person Account fields using Apex. The following describe of Accounts in my sandbox showed Person Account fields such as PersonHomePhone.

Schema.DescribeSObjectResult a = Account.SObjectType.getDescribe();
Map<String,Schema.SObjectField> accountFields = a.fields.getMap();
for (String key: accountFields.keySet()){
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.