• Markus Pallo
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hello,

i need to test a class which needs account.isPersonAccount set.
My test fails, because i am not able to initialize the property inside the test method.

My test method:

@IsTest
    public static void testPersonAccountFields() {
        Schema.RecordTypeInfo recordTypeInfo = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByDeveloperName().get('PersonAccount');
        System.assert(recordTypeInfo != null, 'There must be a Person Account record type');
        String recordTypeId = recordTypeInfo.getRecordTypeId();
        Account account = new Account(RecordTypeId = recordTypeId);
        account.FirstName = 'First';
        account.LastName = 'Last';
        System.assert(account.isPersonAccount, 'must be a person account');
        // here call code which needs is PersonAccount set
    }

any help appreciated.

Markus
Hello,

i need to test a class which needs account.isPersonAccount set.
My test fails, because i am not able to initialize the property inside the test method.

My test method:

@IsTest
    public static void testPersonAccountFields() {
        Schema.RecordTypeInfo recordTypeInfo = Schema.getGlobalDescribe().get('Account').getDescribe().getRecordTypeInfosByDeveloperName().get('PersonAccount');
        System.assert(recordTypeInfo != null, 'There must be a Person Account record type');
        String recordTypeId = recordTypeInfo.getRecordTypeId();
        Account account = new Account(RecordTypeId = recordTypeId);
        account.FirstName = 'First';
        account.LastName = 'Last';
        System.assert(account.isPersonAccount, 'must be a person account');
        // here call code which needs is PersonAccount set
    }

any help appreciated.

Markus