Activity Forums Salesforce® Discussions Can we check when the Person Account was enabled in Salesforce Organization? If yes, how?

  • Ashley

    Member
    January 18, 2018 at 5:55 pm

    Yes, you can check if Person Account is enabled in Salesforce org via Salesforce Apex code. Use this:

    boolean abc = Schema.sObjectType.Account.fields.getMap().containsKey( ‘isPersonAccount’ );
    system.debug(‘@@@’+abc);

    For more details, visit https://www.forcetalks.com/salesforce-topic/whats-the-best-way-to-check-if-person-accounts-are-enabled-via-apex-code/

  • Archit

    Member
    January 19, 2018 at 1:15 pm

    Hello Subodh,

    Please try with below code might be it would be helpful.

    public class TestPersonAccount {
    public static Boolean personAccountsEnabled()
    {
    try
    {
    sObject testObject = new Account();
    testObject.get( 'isPersonAccount' );
    System.debug('Account Enabled');
    return true;
    }
    catch( Exception ex )
    {
    System.debug('Account Disable');
    return false;
    }
    }

    }

  • PRANAV

    Member
    January 22, 2018 at 9:06 am

    Hi Subodh,

    I think you want to know when your org Enables the Person Account. There is not a definite way to check it but you can run the below query to know when the Person Account record type is created.

    Select id,name,createdDate,SobjectType,IsPersonType FROM RecordType WHERE SobjectType='Account' AND IsPersonType=True

    As a new family of record types on Account objects is available: “person account” record types when person account is activated.

    Hope this helps you.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos