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
SunchaserSunchaser 

Error: First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

Hi,

 

We are using the Common Ground Donor Management App on our SalesForce instance.  Besides that we have couple of triggers.  Common Ground has a new upgrade and suddenly our test class begin giving the following error message:

 

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cv.OpportunityAll: execution of AfterInsert caused by: cv.Utils.DesignationException: Error - Please create a default Designation. (cv) : []

 

Stack Trace: Class.UnitTests.testOppsBatch: line 124, column 3 External entry point

 

 

And the code that causes the problem is this:

 

static testmethod void testAcctConBatch() {
    Map<String, Id> recTypesRev = new Map<String, Id>();
    
    //Build a reversed map so that the record type name becomes the Key and the id is the Value.
    for(RecordType rec :[select id, DeveloperName from RecordType]) {
      recTypesRev.put(rec.DeveloperName, rec.Id);
    }

    Account acct1 = new Account(Name = 'Apex Test Household', RecordTypeId = recTypesRev.get('Household'));
    insert acct1;
    
    Contact con1 = new Contact(FirstName = 'Apex Household', LastName = 'Contact1', AccountId = acct1.Id, YTD_Donation_Amount__c = 10,
     Remaining_Recurring_Amount__c = 10, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con1;

    Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

    //Test acctConBatch.
    Test.startTest();
    CalcYTDAccountContactBatch acctConBatch = new CalcYTDAccountContactBatch();
    acctConBatch.queryAcctCon = 'select YTD_All_Contacts__c, (select YTD_Grand_Total__c from Contacts) from Account where Name = \'Apex Test Household\'';
    Id batchprocessID = Database.executeBatch(acctConBatch);
    Test.stopTest();
    
    Account resultAcct = [select YTD_All_Contacts__c from Account where Id = :acct1.Id];
    system.assertEquals(resultAcct.YTD_All_Contacts__c, 60);

  }

 

the following line causes the error:

 

   Contact con2 = new Contact(FirstName = 'Apex Household', LastName = 'Contact2', AccountId = acct1.Id, YTD_Donation_Amount__c = 20,
     Remaining_Recurring_Amount__c = 20, RecordTypeId = recTypesRev.get('HouseholdContact'));
    insert con2;

Since Common Ground is a managed package , I know that this might be a long shot, but still I would appreciate any suggestions or possible fixes.

 

 

Thank you!

 

 

vanessenvanessen

have you tried to use the database.result when inserting,just to be able to catch the errors in a more efficient way ,and to get a better description of the problem??

SunchaserSunchaser

Thank you Vanessen, good suggestion. I managed to solve the problem. Seems like there were some additional fields required, after the upgrade.