• Igor M.
  • NEWBIE
  • 10 Points
  • Member since 2015


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
I have a trigger and a test class, neither of which is able to do a soql query to find a campaign member with the status 'registered'
The trigger works, but on UI it completely ignores the status part and just updates the campaign member anyway, while in test class it fails since it doesn't find any with this status. Am I just misunderstanding how the status gets populated?

Here is the query in my trigger:
   List<CampaignMember> cmList = [SELECT Id, PE_Changed__c, ContactId, Status 
                                   FROM CampaignMember 
                                   WHERE Status = 'Registered'];

Here is my setup in the test class:
        CampaignMember cm1 = new CampaignMember ();
        cm1.ContactId = testcon1.Id;
        cm1.CampaignId = testCampaign.id;
        cm1.Status = 'Registered';
        insert cm1;

When I run the test class and look at the debug log, I see this:
08:02:44:449 USER_DEBUG [85]|DEBUG|cm1: CampaignMember:{ContactId=0032a0000066rW1AAI, CampaignId=7012a000000A8kuAAC, Status=Registered, Id=00v2a000000T1yTAAS}

So I know the setup worked and the status is correctly set. The other interesting part is that if I change my trigger to Status = 'Sent' then it works fine.
We are using AAkonsult Campaign Status app to change campaign statuses, but I don't believe that this should cause any issues.

Any help would be appreciated as I'd like to prevent making so many updates on records that don't need to be updated.
Hi All,

I am getting this error again and again - 

Challenge Not yet complete... here's what's wrong: 
The 'Contact by Hobby' report does not appear to be in the 'General Reports' folder. Whereas I have created the 'Contacts By Hobby' report and saved it in the General Reports folder quite a few number of times, but still getting the same error.

Thanks
Nikhil
I'm trying to get the step -2 and while running the supplied Apex Test, 
Getting below error 

ClassBeAwesome
Method NamehugYourMother
Pass/FailFail
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sb_security.BeAwesome.createUser: line 89, column 1
Class.sb_security.BeAwesome.setup: line 81, column 1


I have created the records owned by Samantha as mentioned and also created sharing rule for Project managers.
Can someone please help ?