Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error deploying Child Trigger on NPSP object npe03_Recurring_Donation #490

Closed
RWAPS opened this issue Apr 16, 2017 · 10 comments
Closed

Error deploying Child Trigger on NPSP object npe03_Recurring_Donation #490

RWAPS opened this issue Apr 16, 2017 · 10 comments

Comments

@RWAPS
Copy link

RWAPS commented Apr 16, 2017

Hello everyone, I've upgraded to V2.8 of DLRS in my sandbox, and some Roll up summaries work fine (using the new flavour with custom metadata, via the "Manage Lookup Rollup Summaries" tab) while others, where the child object is "npe03__Recurring_Donation__c" from the Salesforce Foundation NPSP, fail to deploy.
I get 2 errors, any idea?

Error:
dlrs_npe03_Recurring_DonationTest.testTrigger System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, You must select an Organization or Contact: [] Class.dlrs.RollupService.testHandler: line 272, column 1 Class.dlrs_npe03_Recurring_DonationTest.testTrigger: line 11, column 1

Warning:
dlrs_npe03_Recurring_DonationTrigger:Test coverage of selected Apex Trigger is 0%, at least 75% test coverage is required

My understanding from reading other issues here is that I can solve #2 by adding a custom test class (but where?), and #1 seems to be a recurring issue in relation to DLRS with NPSP (issue #197). Any updates on DLRS with NPSP? Thanks so much!
image

@afawcett
Copy link
Collaborator

Yes you need to provide some custom test code in the Test Code field, i am not an expert in NPSP, hopefully someone in the Chatter group has the test code fragment you need. Meanwhile this is the background to both your errors https://github.com/afawcett/declarative-lookup-rollup-summaries/wiki/Challenges-with-Code-Coverage

@benchastain
Copy link

benchastain commented May 2, 2017

@RWAPS Did you ever manage to solve your test code issue?

I just wrote test code for a trigger that rolls up recurring donations to the contact record and if you're trying to do something similar then I'd imagine my test code will work for you.

I believe I received the same error as you did in my first go round--it's because there's a validation rule on the Recurring Donation object to assign either a contact or an organization. You can do that in your test code like this (my test code also needed the custom field 'Inactive_Recurring_Gift__c' to be false):

Contact con = new Contact(Lastname = 'Test');
insert con;

SavePoint sp = Database.setSavepoint();
dlrs.RollupService.testHandler(new npe03__Recurring_Donation__c(npe03__Contact__c = con.id, Inactive_Recurring_Gift__c = FALSE));
Database.rollback(sp);

Just a final bit--if you have other validation rules on the contact object, then you need to turn them off to get this to work (we had a validation where you needed to enter a first time that I turned off to get it to pass the tests and deploy).

@RWAPS
Copy link
Author

RWAPS commented May 2, 2017

Hi @benchastain, thanks, yes I did manage to solve this. Thanks for the additional information.

@afawcett
Copy link
Collaborator

Thanks for sharing @benchastain, i dont have NPSP experience so depend on this kind of contribution from the community to help others. Thank you! 👍

@BHFoundation
Copy link

I could use some assistance on this same item except I am trying to roll up the GAU Allocations to the Opportunity record. We are recording the GAU Allocations on through a lookup on the opportunity and upon save this creates the Allocation records. But I need to verify the allocation totals equal the opportunity total. Any assistance would be greatly appreciated.

@BHFoundation
Copy link

Sorry here is the error I am receiving ......

image

@alexandr-yul
Copy link

alexandr-yul commented Feb 16, 2018

@benchastain I wasn't able to use your code directly (it gave an error) but the following worked

    Contact con = new Contact(Lastname = 'Test');
    insert con;

    npe03__Recurring_Donation__c recur = new npe03__Recurring_Donation__c();
    recur.npe03__Installment_Period__c = 'Monthly';
    recur.npe03__Open_Ended_Status__c = 'Open';
    recur.npe03__Schedule_Type__c = 'Multiply By';
    recur.npe03__Amount__c = 50;
    recur.npe03__Date_Established__c = System.Today();
    recur.npe03__Next_Payment_Date__c = System.Today();
    recur.npe03__Contact__c = con.Id;
    
    SavePoint sp = Database.setSavepoint();
    dlrs.RollupService.testHandler(recur);
    Database.rollback(sp);

@benchastain
Copy link

benchastain commented Feb 16, 2018 via email

@afawcett
Copy link
Collaborator

Reminder to include this when delivering this idea, #613.

@afawcett
Copy link
Collaborator

I will close this out for now. We can keep chatting though and re-open the case if needed. Thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants