Declarative Rollup Summary - error
I want to create a Declarative Rollup Summary , but I hit the following error :
dlrs_pse_AssignmentTest.testTrigger System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Bill Rate is required: [pse__Bill_Rate__c] Class.dlrs.RollupService.testHandler: line 282, column 1 Class.dlrs_pse_AssignmentTest.testTrigger: line 11, column 1
Scenarios is as follow :
Parent object : pse__Milestone__c
Child Object : pse__Assignment__c
Relationship field : pse__Milestone__c
Field to aggregate : Days_Active__c
Aggregate result field : Days_Active_Roll_Up__c
Manage child trigger :
/** * Auto Generated and Deployed by the Declarative Lookup Rollup Summaries Tool package (dlrs) **/ trigger dlrs_pse_AssignmentTrigger on pse__Assignment__c (before delete, before insert, before update, after delete, after insert, after undelete, after update) { dlrs.RollupService.triggerHandler(pse__Assignment__c.SObjectType); } /** * Auto Generated and Deployed by the Declarative Lookup Rollup Summaries Tool package (dlrs) **/ @IsTest private class dlrs_pse_AssignmentTest { @IsTest private static void testTrigger() { // Force the dlrs_pse_AssignmentTrigger to be invoked, fails the test if org config or other Apex code prevents this. dlrs.RollupService.testHandler(new pse__Assignment__c()); } }
Why getting declarative lookup rollup summaries? What might be the issue? I have deactivated the validation rule but still have this error.
The field might be set to be required at the object level. You can modify the test created to include values for the pse__Assignment__c object that is inserted in the test.
To do this, you should build the rollup in a sandbox first. Then you can edit the dlrs_pse_AssignmentTest class and modify the line
dlrs.RollupService.testHandler(new pse__Assignment__c()); } }
to be something like
dlrs.RollupService.testHandler(new pse__Assignment__c(pse__Bill_Rate__c = 1)); } }Once the test passes in the sandbox, then you can deploy using a change set or other tools.
See https://github.com/afawcett/declarative-lookup-rollup-summaries/wiki/Challenges-with-Code-Coverage for more information.