I am trying to create a unit test in Financial Services Cloud that tests operations on Household Roles. The org uses Person Accounts. Whenever I try and insert an AccountContactRelation with the Person Account set as primary (FinServ__Primary__c = true), the insertion fails with the following error:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Can't choose a business as a primary group or primary member.: []

Here is my setup method. It creates an account with RecordType of 'Client Household'. Then it creates a Person Account. Finally, I attempt to relate the two accounts by inserting a record into AccountContactRelation.

@testSetup static void setup() 
    RecordType householdRecordType =  [SELECT Id FROM RecordType WHERE (Name = 'Household') AND (SObjectType = 'Account')];
    Account a = new Account(
        Name = 'Test Household',
        RecordType = householdRecordType
    insert a;

    RecordType personAccountRecordType = [SELECT Id FROM RecordType WHERE (Name = 'Person Account') AND (SObjectType = 'Account')];
    Account pa = new Account(
        FirstName = 'Test',
        LastName = 'Person Account',
        RecordType = personAccountRecordType,
        FinServ__IndividualType__c = 'Individual'
    insert pa;

    // Need to get the PersonContactId for the Person Account
    pa = [SELECT PersonContactId FROM Account WHERE Id = :pa.Id];

    AccountContactRelation acr = new AccountContactRelation(
        AccountId = a.Id,
        ContactId = pa.PersonContactId,
        IsActive = true,
        FinServ__PrimaryGroup__c = true,
        FinServ__Primary__c = true,
        Roles = 'Client',
        FinServ__Rollups__c = 'Tasks;Events;Financial Accounts'
    insert acr;
  • That is caused by either a validation rule or an Apex trigger addError(). Have you checked your validation rules and unmanaged Apex? Commented Mar 23, 2020 at 22:57
  • This appears to be coming from Salesforce's FSC managed package, but I can't narrow down where. Commented Mar 23, 2020 at 23:40
  • You'll probably need to open a case with Salesforce. Commented Mar 24, 2020 at 3:55
  • Okay, it turns out that querying the RecordType object is not the way to do this. I should have used the Schema.SObjectType.Account.getRecordTypeInfosByName() method instead. Commented Mar 24, 2020 at 16:50

1 Answer 1


The proper way to get the RecordTypeId is to use the Schema.SObjectType.Account.getRecordTypeInfosByName() method, not by querying the RecordType object.

Id householdRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Household').getRecordTypeId();
Id personRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .