function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ganta SureshGanta Suresh 

Hello Every one for the below test call , getting below error , could someone help me on this

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AcuteFacilityTrigger: execution of AfterInsert

caused by: System.DmlException: Update failed. First exception on row 0 with id a3vD70000011WczIAE; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Palmer Group: bad value for restricted picklist field: Test Group: [Palmer_Group__c]

Class.AcuteFacilityHandler.updateAgreement: line 22, column 1
Trigger.AcuteFacilityTrigger: line 3, column 1: []

Testcalss:-
@isTest
public class AcuteFacilityTriggerTest {

    public static testmethod void AcuteFacilityTest() {
        Id agrRecordType = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Medical Director Agreement (MDA)').getRecordTypeID();
        ID ACC_RT = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Dialysis Centers').getRecordTypeID();

        Test.startTest();

        Legal_Entity__c le = new Legal_Entity__c();
        le.State__c = 'Alaska';
        le.Name = 'Test Legal Entity';
        insert le;

        Account ac = new Account();
        ac.Name = 'test Account';
        ac.RecordTypeId = ACC_RT;
        ac.Type = 'Denovo';
        ac.BillingPostalCode = '41011';
        ac.BillingCity = 'covington';
        ac.BillingState = 'KY';
        ac.BillingCountry = 'USA';
        ac.BillingStreet = '1500 JAMES SIMPSON JR WAY, STE 1100';
        //Changed as Group__c to Palmer_Group__c 12/06/2023
        //ac.Group__c = 'Apex';
        ac.DVA_Facility_Number__c = 555;
        ac.Legal_Entity2__c = le.Id;
        ac.MDM_Group__c = 'Test Group';
        ac.MDM_Division_Mapped__c = 'Test Division';
        insert ac;

        Apttus__APTS_Agreement__c agg = new Apttus__APTS_Agreement__c();
        agg.RecordTypeId = agrRecordType;
        insert agg;

        Acute_Facility__c acc = new Acute_Facility__c();
        acc.Agreement__c = agg.Id;
        acc.Facility_Name__c = ac.Id;
        insert acc;

        Apttus__APTS_Agreement__c agr = [Select Davita_Legal_Entity_2__c, Division__c, Palmer_Group__c, Facility_Name_for_Template__c, Facility_Number_for_Template__c from Apttus__APTS_Agreement__c where Id =: agg.Id];
        Acute_Facility__c af = [Select MDA_Fac_Davita_legal_Entity__c, Facility_Division__c, Facility_Group__c, Facility_Number__c, Facility_Name_Acute__c from Acute_Facility__c where Id =: acc.Id];
        System.assertEquals(agr.Davita_Legal_Entity_2__c, af.MDA_Fac_Davita_legal_Entity__c);
        System.assertEquals(agr.Division__c, af.Facility_Division__c);
        System.assertEquals(agr.Palmer_Group__c, af.Facility_Group__c);
        System.assertEquals(agr.Facility_Name_for_Template__c, af.Facility_Name_Acute__c);
        System.assertEquals(agr.Facility_Number_for_Template__c, af.Facility_Number__c);

        Test.stopTest();
    }


}

Class:-

trigger AcuteFacilityTrigger on Acute_Facility__c(after insert, after update) {

    AcuteFacilityHandler.updateAgreement(trigger.New);
}
Best Answer chosen by Ganta Suresh
SwethaSwetha (Salesforce Developers) 
HI Suresh,
As the error suggests, the value "Test Group" being assigned to the picklist field "Palmer_Group__c" is not a valid option for the picklist field.

Can you verify that the picklist field values used in your test class are valid and match the available options for the field? Make sure that the picklist value "Test Group" is a valid option for the field "Palmer_Group__c"

Related: https://salesforce.stackexchange.com/questions/229088/restricted-picklist-issue-even-providing-correct-value

https://help.salesforce.com/s/articleView?id=000384095&type=1

https://salesforce.stackexchange.com/questions/150504/picklist-value-not-recognized-in-the-test

If this information helps, please mark the answer as best. Thank you