Friday, May 22, 2015

Test for person account.

We basically just need to grab the correct account type record id and assign it to the account and you of course need person accounts enabled on your org.

String RecordTypeId = [SELECT Id FROM RecordType WHERE (Name = 'Person Account') AND (sObjectType = 'Account')].Id;
Account a = new Account(
RecordTypeID = RecordTypeId,
LastName = System.now().millisecond() + 'Testing Lastname'
);
insert a;

No comments:

Post a Comment