2

I am about to create a new managed package on top of Financial Service Cloud and I noticed I get errors on my test classes after adding the namespace. I tried copying a line and run it on dev console.

        Account householdAcc = new Account(
            Name = 'Sample Household',
            RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Household').getRecordTypeId()
        );
        insert householdAcc;

and I get an error below:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, FinServ.AccountTrigger: execution of BeforeInsert caused by: FinServ.MoiExceptionWrapper.ValidationException: Your account record type is missing, a duplicate, or invalid. Ask your admin to check the individual record type configurations in Setup. Class.FinServ.MoiConfiguration: line 644, column 1 Class.FinServ.MoiConfiguration: line 598, column 1 Class.FinServ.MoiConfiguration.loadIndividualRecordTypeMapping: line 559, column 1 Class.FinServ.MoiConfiguration: line 739, column 1 Class.FinServ.MoiConfiguration.isRecordOfTypeIndividual: line 812, column 1 Class.FinServ.AccountTriggerHandler.onBeforeInsert: line 31, column 1 Class.FinServ.MoiBaseTriggerHandler.handleEvent: line 119, column 1 Trigger.FinServ.AccountTrigger: line 12, column 1: []

I already checked everything and did not have any errors before packaging/namespace addition and I am now stuck.

I also tried adding an account record manually and it shows the same error. enter image description here

Has anyone experience this or knows how to fix this?

0

Briefly, after installing nCino in our enterprise org we discovered duplicate record types names. The problem is a record type's developer name is not unique by itself. Developers must also include the namespace.

Try adding namespaceprefix to the SELECT. Here's an example from our FsbQuery class.

public static RecordType GetRecordType(string anSobjectType, string aDeveloperName)
{
    return GetRecordType(anSobjectType, aDeveloperName, null);
}

public static RecordType GetRecordType(string anSobjectType, string aDeveloperName, string aNamespacePrefix)
{
    anSobjectType = anSobjectType.toLowerCase();
    RecordTypeMap = GetRecordTypeMap();
    list<RecordType> aList = RecordTypeMap.get(anSobjectType);
    if (aList == null || aList.isEmpty())
        return null;

    for (RecordType each : aList) {
        if (each.developerName.equalsIgnoreCase(aDeveloperName) &&
        (each.nameSpacePrefix == aNamespacePrefix || each.NameSpacePrefix.equalsIgnoreCase(aNamespacePrefix)))
        return each;
    }

    return null;
}
1
  • I can get the id correctly (checked it via query). I can't seem to use it even if I manually set RecordId to that value. Also, in the Account record type, the record types available are Individual, Household, Business, Institution (all four from FinServ) and PersonAccount. Another thing is I used the same exact code on another managed package(extension) with FinServ and it worked fine even after being packaged. – Micz Domz Nov 11 '18 at 13:30
0

This might not be the answer but would shed some light on the error.

The error you are getting is not standard record type or validation rule exception. Its an exception from Class.FinServ.MoiConfiguration.loadIndividualRecordTypeMapping:

The reason it works in execute anon is that the Individual Record Mapping is present in the sandbox. But in Test environment, as you are not creating that mapping it's throwing that exception.

If you can go through the code of FinServ.MoiConfiguration.loadIndividualRecordTypeMapping and see which object/custom-setting is queried and insert the same config in your test method it will solve the validation error.

1
  • It also does not work in execute anon. Also, FinServ.MoiConfiguration.loadIndividualRecordTypeMapping is part of another managed package so I don't think I can go through its code. – Micz Domz Nov 11 '18 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.