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

I am not a developer so sometime struggle with troubleshooting #197

Open
GregDevine opened this issue Jun 29, 2015 · 28 comments
Open

I am not a developer so sometime struggle with troubleshooting #197

GregDevine opened this issue Jun 29, 2015 · 28 comments

Comments

@GregDevine
Copy link

I am trying to roll up from campaign member to a related Lookup Object (enrolment)
Get this error message when trying to deploy the trigger

dlrs_CampaignMemberTest.testTrigger System.DmlException: Insert failed. First exception on row 0; first error: MALFORMED_ID, Invalid campaign id: null: CampaignId Class.dlrs_CampaignMemberTest.testTrigger: line 10, column 1

Any suggestions what I should be looking for?

@GregDevine
Copy link
Author

Have just tested in a sandbox and rollup works there but not in production

@GregDevine
Copy link
Author

Actually the test on campaignmember test failed in saandbox

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

The generated Apex test by the tool is pretty dumb, in most cases its been fine, but i now see an upturn in cases where it needs more sophstication, unfortunatly the tool itself cannot figure out what code to write on its own. What it can do is make it easier for a developer or someone more technical to give you a snipet of code to give to the rollup tool that it injects that will fullfil these type of requirements. In your case it looks like the CampaignMember child object needs the parent Id. I've got already an enhancement to offer this kind of customisation over the generated test marked here, but i'll leave this one open as a reminder of a use case to test with whatever enhancement feature is produced. In the meantime you will need to get a developer to help you with the generated test. I'll post a blog post in the next few days to outline these types of problems, solutions today, and solutions in the pipeline. Sorry in the meantime for this.

POSSIBLE FIX NOTE: One option in this case actually might be to auto generate fake Id's for relationship fields?

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

I've recently written up some shared details on the code coverage issue described in this case, please check the details here and comment at the bottom of the wiki page.

@GregDevine
Copy link
Author

Many thanks
Will work through that later today

Regards
Greg Devine

+64 274 338 463 (+64 274 DEVINE)
[email protected]

Manukau Road Consulting
Using our Past and our Present to Build our Future

www.manukauroad.com http://www.manukauroad.com

On 2 July 2015 at 06:57, Andrew Fawcett [email protected] wrote:

I've recently written up some shared details on the code coverage
https://github.com/afawcett/declarative-lookup-rollup-summaries/wiki/Challenges-with-Code-Coverage
issue described in this case, please check the details here and comment at
the bottom of the wiki page.


Reply to this email directly or view it on GitHub
#197 (comment)
.

@GregDevine
Copy link
Author

Thanks
Working now
Took me a little bit longer than it would have if I was a developer - but
there now.
Once again a fantastic product - and I'll know where to look and what to
do next time.

Regards
Greg Devine

+64 274 338 463 (+64 274 DEVINE)
[email protected]

Manukau Road Consulting
Using our Past and our Present to Build our Future

www.manukauroad.com http://www.manukauroad.com

On 2 July 2015 at 07:56, Greg Devine [email protected] wrote:

Many thanks
Will work through that later today

Regards
Greg Devine

+64 274 338 463 (+64 274 DEVINE)
[email protected]

Manukau Road Consulting
Using our Past and our Present to Build our Future

www.manukauroad.com http://www.manukauroad.com

On 2 July 2015 at 06:57, Andrew Fawcett [email protected] wrote:

I've recently written up some shared details on the code coverage
https://github.com/afawcett/declarative-lookup-rollup-summaries/wiki/Challenges-with-Code-Coverage
issue described in this case, please check the details here and comment at
the bottom of the wiki page.


Reply to this email directly or view it on GitHub
#197 (comment)
.

@afawcett
Copy link
Collaborator

afawcett commented Jul 3, 2015

Excellent! As i said in the Wiki hopefully a future version can take some of the tooling pain out of it, if not the coding bit for these such use cases.

@afawcett afawcett closed this as completed Jul 3, 2015
@Rnatik
Copy link

Rnatik commented Jul 13, 2015

Hey Greg, can you pls explain what you did? Facing the same issue here. thanks

@GregDevine
Copy link
Author

As I said I'm not a developer - so what i did may have been
inelegant/incorrect - but it worked.
I Added some extra items to the terst class. - It was on campaign Members
so I added "create a contact" - to the test class which is required for a
Campaign Member

Regards
Greg Devine

+64 274 338 463 (+64 274 DEVINE)
[email protected]

Manukau Road Consulting
Using our Past and our Present to Build our Future

www.manukauroad.com http://www.manukauroad.com

On 14 July 2015 at 11:28, Rnatik [email protected] wrote:

Hey Greg, can you pls explain what you did? Facing the same issue here.
thanks


Reply to this email directly or view it on GitHub
#197 (comment)
.

@afawcett
Copy link
Collaborator

Would you mind sharing @GregDevine the code here for future users with the issue? It's OK if not.

@afawcett
Copy link
Collaborator

@GregDevine looks like we've got another user struggling with CampaignMember are you able to paste a snippet of your test code here please? No worries if not.

@GregDevine
Copy link
Author

Will do
On 30/08/2015 7:40 PM, "Andrew Fawcett" [email protected] wrote:

@GregDevine https://github.com/GregDevine looks like we've got another
user struggling with CampaignMember are you able to paste a snippet of your
test code here please? No worries if not.


Reply to this email directly or view it on GitHub
#197 (comment)
.

@GregDevine
Copy link
Author

No idea if its "robust" - was my first ever test class
that wan't just "copied from" a google serach

/**

  • Auto Generated and Deployed by the Declarative Lookup Rollup
    Summaries Tool package (dlrs)
    **/
    @istest
    private class dlrs_CampaignMemberTest
    {
    private static testmethod void testTrigger()
    {Campaign c=new Campaign(Name='Test');
    insert c;
    Contact con=new Contact(Lastname='fred');
    insert con;

    // Force the dlrs_CampaignMemberTrigger to be invoked, fails
    

    the test if org config or other Apex code prevents this.
    SavePoint sp = Database.setSavepoint();
    dlrs.RollupService.testHandler(
    new CampaignMember(campaignid=c.id, Contactid=con.id));
    Database.rollback(sp);
    }
    }

Regards
Greg Devine

+64 274 338 463 (+64 274 DEVINE)
[email protected]

Manukau Road Consulting
Using our Past and our Present to Build our Future

www.manukauroad.com http://www.manukauroad.com

On 30 August 2015 at 19:40, Andrew Fawcett [email protected] wrote:

@GregDevine https://github.com/GregDevine looks like we've got another
user struggling with CampaignMember are you able to paste a snippet of your
test code here please? No worries if not.


Reply to this email directly or view it on GitHub
#197 (comment)
.

@JenNelsonChicago
Copy link

Thanks for adding your code, @GregDevine - did you just copy the whole thing into Test Code field? I am still getting errors, now about things like setting variables to private or test...

/**

  • Auto Generated and Deployed by the Declarative Lookup Rollup
    Summaries Tool package (dlrs)
    **/
    @istest
    private class dlrs_CampaignMemberTest
    {
    private static testmethod void testTrigger()
    {Campaign c=new Campaign(Name='Test');
    insert c;
    Contact con=new Contact(Lastname='fred');
    insert con;

    // Force the dlrs_CampaignMemberTrigger to be invoked, fails
    

    the test if org config or other Apex code prevents this.
    SavePoint sp = Database.setSavepoint();
    dlrs.RollupService.testHandler(
    new CampaignMember(campaignid=c.id, Contactid=con.id));
    Database.rollback(sp);
    }
    }

@afawcett
Copy link
Collaborator

Hi @JenNelsonChicago

Just copy this bit... you don't need the See All Data tickbox for this...

Campaign c=new Campaign(Name='Test');
insert c;
Contact con=new Contact(Lastname='fred');
insert con;

// Force the dlrs_CampaignMemberTrigger to be invoked, fails the test if org config or other Apex code prevents this.
SavePoint sp = Database.setSavepoint();
dlrs.RollupService.testHandler(
    new CampaignMember(campaignid=c.id, Contactid=con.id));
Database.rollback(sp);

@afawcett
Copy link
Collaborator

@GregDevine thanks btw! 👍

@SusanTro
Copy link

Sorry for the dumb question but where do I paste the test code? JenNelsonChicago references a Test Code field. Where do I find that?

Thanks!

@afawcett
Copy link
Collaborator

Take a look at this #307

@Rnatik
Copy link

Rnatik commented Jun 2, 2016

You need to remove some of the lines. It was confusing for me as well. can
you email me in an hour and I will send you the exact code to use?
On Jun 2, 2016 10:14 AM, "JodiNA" [email protected] wrote:

Hi @afawcett https://github.com/afawcett - I tried the test code you
gave to Jen, and I'm still getting the same error. What am I missing?

I was glad to see that this is already something others have experienced
and figured out a workaround to manage (even if that workaround isn't
working for me yet!).

Jodi

[image: dlrs_rollup]
https://cloud.githubusercontent.com/assets/8515331/15747888/b78d5942-28aa-11e6-827a-374bf6fb9582.jpg
[image: dlrs_error]
https://cloud.githubusercontent.com/assets/8515331/15747890/b9a19ad6-28aa-11e6-9c19-2952e83cfddf.jpg


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#197 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AMtMPfiQF5Sk-l6Y3mBOee5HsNOv8OILks5qHuU_gaJpZM4FN0qZ
.

@JodiNA
Copy link

JodiNA commented Jun 2, 2016

@Rnatik - I actually deleted my post because I realized that it was a validation problem from within my instance, not an issue with the code Andy provided. THANK YOU for responding, though!

I was able to add an additional variable assignment to the test code, and now it works.

Again, very appreciative to have this thread with the test code solution. Thanks @afawcett and everyone else!

@afawcett
Copy link
Collaborator

afawcett commented Jun 7, 2016

Thanks @JodiNA, and btw i keep running up to that NPSP issue and runny away, its really hard to debug, i think i'm going to have to deploy both NPSP and DLRS into an org unmanaged so i can see all the code and get detailed debug logs. Sorry i feel bad its still hanging around that issue. It really requires a day to debug. I'm actually wondering if I could hack it through with an NPSP dev together at an MVP event or something?

@JodiNA
Copy link

JodiNA commented Jun 16, 2016

@afawcett - regarding the NPSP issue, I'm not exactly sure where to point you with this one. Judi Sohn or David Habib might be people to reach out to.

@afawcett
Copy link
Collaborator

Thanks, are either of them close or in town during the MVP LEX event do you know?

@JodiNA
Copy link

JodiNA commented Jun 17, 2016

No idea, sorry!

On Fri, Jun 17, 2016 at 1:32 PM, Andrew Fawcett [email protected]
wrote:

Thanks, are either of them close or in town during the MVP LEX event do
you know?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#197 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AIHvA6a3zZAIy7J4vr_YzB1exDSSJ6Tlks5qMtokgaJpZM4FN0qZ
.

Jodi Nemser-Abrahams
Information & Data Manager
Keshet
284 Amory Street
Boston, MA 02130
617.524.9227x111

Web: www.keshetonline.org
Facebook: www.facebook.com/KeshetGLBTJews
Twitter: @KeshetGLBTJews https://twitter.com/KeshetGLBTJews
Blog: www.myjewishlearning.com/category/keshet/

Join us for Keshet Cabaret
http://www.keshetonline.org/event/keshetcabaret2016/ on Thursday, June
23rd
_!_ Tickets are only $36 for a raucous, fun, and fabulous night
celebrating Keshet’s work, Pride Month, and our community in Boston!

Celebrate Pride Month http://www.keshetonline.org/pride/ with Keshet!
Click here https://www.keshetonline.org/pride/commitment/ to share your
organization's commitment to marking the month!

Stand up for transgender rights. Sign Keshet's petition
https://www.keshetonline.org/work/petition-in-support-of-full-transgender-rights-in-massachusetts/support-transgender-rights-in-ma/
calling
Massachusetts legislators to support “An Act Relative to Transgender
Anti-Discrimination."

@lauramccraven
Copy link

I'm running into this issue but on a Custom Object. I tried using the Campaign Member code and tweaking but I'm not doing it right. What is the root cause of this issue so I can understand what I'm trying to fix? Is it something that is required for the creation of one of the records that throws the error during the test class? THANK YOU!

@ashlynnrs
Copy link

I am getting the same error. Not sure what is applicable to my case from the above comments and solutions.

Heres my Error:
dlrs_CampaignMemberTest.testTrigger System.DmlException: Insert failed. First exception on row 0; first error: MALFORMED_ID, Invalid campaign id: null: [CampaignId] Class.dlrs.RollupService.testHandler: line 282, column 1 Class.dlrs_CampaignMemberTest.testTrigger: line 11, column 1

Here's my test class:
trigger dlrs_CampaignMemberTrigger on CampaignMember
(before delete, before insert, before update, after delete, after insert, after undelete, after update)
{
dlrs.RollupService.triggerHandler(CampaignMember.SObjectType);
}
@istest
private class dlrs_CampaignMemberTest
{
@istest
private static void testTrigger()
{
// Force the dlrs_CampaignMemberTrigger to be invoked, fails the test if org config or other Apex code prevents this.
dlrs.RollupService.testHandler(new CampaignMember());
}
}

No active validation rules on parent or child objects. There are two existing managed triggers on the Campaign object, which shouldn't affect things since this is a Campaign Member trigger. I am wondering whether this code snippet copied from above will fix my coverage:

Campaign c=new Campaign(Name='Test');
insert c;
Contact con=new Contact(Lastname='fred');
insert con;

Where do I put it, in the existing class? Thanks so much. I have never had this issue with a rollup and have yet to write a single line of code, so grateful for whatever light others can shed here.

@JimBTek
Copy link
Collaborator

JimBTek commented May 21, 2019

you are failing to have an Id MALFORMED_ID, Invalid campaign id: null: [CampaignId] . But if you are not a developer, why not just let DLRS deploy the Child Trigger for you? It should come with test coverage and not require you to write any code.

@ashlynnrs
Copy link

ashlynnrs commented May 21, 2019 via email

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

9 participants