0

I am getting in MyTestClass

System.DmlException: Update failed. First exception on row 0 with id 00N000000FqP2cIAF; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

I tried to access the id 00N000000FqP2cIAF but is in error, cannot access, might be deleted.

@isTest private static void testWhoCanCloseCasebeforeUpdate() {

        set<string> setfedids = new set<string>();
        List <Insurance_Claims_Case__mdt> cmsetting = [SELECT DeveloperName, Federation_ID__c FROM Insurance_Claims_Case__mdt];
        for (Insurance_Claims_Case__mdt icc: cmsetting){
            setfedids.add(icc.Federation_ID__c);
        }

       User triggerUser = [Select id, FederationIdentifier FROM User WHERE isActive = true AND FederationIdentifier = 'Icandothis' limit 1];

       Account acc = [Select Id from Account limit 1];
       Contact con = [Select Id from Contact limit 1];

       Case cs = new Case ();
            cs.RecordTypeId = Constants.RECORDTYPEID_CLAIM;
            cs.Subject = 'ClaimCase';
            cs.Status = 'Insurer’s Decision';
            cs.Origin = 'Phone'; 
            cs.Claim_Outcome_Reason__c = 'Difficultyt'; 
            cs.Payment_Amount__c = 2000; 
            cs.Sum_Insured__c = 20000; 
            cs.Premium_Refund_Value__c = 34000;
            cs.All_relevant_information_in_DataRooms__c ='Yes'; 
            cs.Date_referred_to_Client_Care_Services__c = date.today(); 
            cs.Trustee_Recommendation__c =  'Admit'; 
            cs.Trustee_Recommendation_Reason__c = 'Met terms and conditions'; 
            cs.Trustee_Next_Action__c = 'Prepare letter';
            cs.AccountId = acc.Id;
            cs.ContactId = con.Id;
            insert cs; 

        System.runas(triggerUser) {



            Test.startTest();
            cs.Status = 'Claim Decision';
            cs.Claim_Outcome__c = 'Successfully Closed'; 
            update cs;
            Test.stopTest();
        }
   }
  • Could you please share the entire stack trace and which line throws the error? – David Reed Mar 8 at 17:53
  • System.DmlException: Update failed. First exception on row 0 with id 500N000000FqP2cIAF; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] – OneFourFour Mar 8 at 22:32
  • on line update cs; – OneFourFour Mar 8 at 22:33
2

00N000000FqP2cIAF has 17 characters, and is therefore not a valid ID. All ID values are either 15- or 18-characters in length. You have a typo somewhere. In addition, a 00N would be a CustomFieldDefinition, there wouldn't be any normal reason to use this ID except in very rare circumstances, and I don't see any reason why you'd need that ID in your unit test. You'll need to verify the correct ID to use for whatever field it is you're trying to populate (I suspect it's the RecordTypeId field, since that's the only constant, but I could be wrong). Try doing a search in your code base for that invalid ID, and you should be able to find it.

| improve this answer | |
  • System.DmlException: Update failed. First exception on row 0 with id 500N000000FqP2cIAF; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: [] – OneFourFour Mar 8 at 22:32
  • on line update cs; the error throws – OneFourFour Mar 8 at 22:33
  • 1
    @OneFourFour Then the problem is likely in a trigger somewhere. We don't have enough code to figure out what's up. – sfdcfox Mar 8 at 22:38
  • I check the ID from UI and it shows in the address line ..force.com/lightning/r/Case/500N000000FqPN4IAN/view here the messageLooks like there's a problem. We couldn't find the record you're trying to access. It may have been deleted by another user, or there may have been a system error. Ask your administrator for help. ..... If I will add the permission set how will I include on the test class – OneFourFour Mar 8 at 23:06
  • 1
    @OneFourFour Data created in unit tests do not persist. You won't be able to check it that way. Your problem is elsewhere. – sfdcfox Mar 8 at 23:54

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.