1

The exact error message is

System.DmlException: Insert failed. First exception on row 0; first error: >CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, HealthCloudGA.AccountTrigger: execution of >BeforeInsert caused by: HealthCloudGA.MoiExceptionWrapper.ValidationException: There is >more than one Individual record type for Account or Contact. The record type must be >unique. Contact your administrator for help.

I have a simple test class (auto-generated by the DLRS package) that is attempting to create a new account to test a trigger.

We are using HealthCloud with PersonAccounts.

Many similar errors say to check the Account and Contact to ensure the Custom Metadata settings are correct. The Individual record type's settings are part of the Health Cloud package. I can't change anything with them.

Also, I attempted to make sure there was only one Individual record type, per the error message, but that is also controlled by HealthCloud and cannot be changed.

I have also checked for mandatory filters that require values (grasping at straws) and made sure to pass those in (hard-coded while hacking away to see if I can get it to work). No success.

Update - Mar 15

I have changed the code to resemble the suggestion below. The results are the same.

@IsTest
private class dlrs_AccountTest
{
    @IsTest
    private static void testTrigger()
    {
        // Force the dlrs_Physician_ReviewTrigger to be invoked, fails the test if org config or other Apex code prevents this.
        Map <String,Schema.RecordTypeInfo> recordTypesadjustment = Account.sObjectType.getDescribe().getRecordTypeInfosByDeveloperName();
        Id recordTypeId = recordTypesadjustment.get('Care_Management').getRecordTypeId();

        Account acc = new Account(RecordTypeId=recordTypeId);
        System.debug(acc);
        Test.startTest();
        dlrs.RollupService.testHandler(acc);
        Test.stopTest();
    }
}
2
  • hard-coded IDs in the testmethod is the road to ruin when it comes to deployment; you should mock the Clinic Location and Clinic Accounts
    – cropredy
    Commented Mar 14, 2023 at 23:05
  • thanks for the feedback. I realize that, which is why i said in the question that they were only there to see if I can get this past the error message.
    – tryinHard
    Commented Mar 14, 2023 at 23:45

1 Answer 1

0

Financial Services Cloud and Health Cloud

Description

Users may see the following error when creating an Account record:

Your account record type is missing, a duplicate, or invalid. Ask your admin to check the group record type configurations in Setup. Resolution

This error will be observed if:

  1. The 'Household' record type has been deactivated on the Account object
  2. The 'Individual' record type has been deactivated on the Account object
  3. The 'Individual' record type has been deactivated on the Contact object

To resolve the above issues you need to reactivate the record types and consider removing access to the record types at the profile (or permission set) level.

This error will also be observed if there is an Account record type with a Name (DeveloperName) that matches to the Name (Developer Name) of a Person Account Record Type. Source here

Change the code to

@IsTest
private class dlrs_AccountTest
{
    @IsTest
    private static void testTrigger()
    {
        // Force the dlrs_Physician_ReviewTrigger to be invoked, fails the test if org config or other Apex code prevents this.
        Map <String,Schema.RecordTypeInfo> recordTypesadjustment = Account.sObjectType.getDescribe().getRecordTypeInfosByDeveloperName();
        Id recordTypeId = recordTypesadjustment.get('Individual').getRecordTypeId();

        Account acc = new Account(Name='Test Unit Account', RecordTypeId=recordTypeId, Clinic_Account__c='REMOVE HARD CODING', Clinic_Location__c='REMOVE HARD CODING');
        System.debug(acc);
        Test.startTest();
        dlrs.RollupService.testHandler(acc);
        Test.stopTest();
    }
}
3
  • Slightly different error. In my org, all of those types are activated, and there are no conflicting Account and Person Account record types. Thanks for the suggestion.
    – tryinHard
    Commented Mar 15, 2023 at 0:49
  • CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY - its a field update issue when it tries to update the same record which is currently in execution. Have you tried with getting record type by developername Commented Mar 15, 2023 at 1:01
  • Thanks again. The suggested code provided the same result as before.
    – tryinHard
    Commented Mar 15, 2023 at 4:43

You must log in to answer this question.

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