• Igor Makarov
  • NEWBIE
  • 0 Points
  • Member since 2017
  • Salesforce Administrator
  • TechTarget

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I recently found out that when Email to Salesforce is used and there are multiple To: contacts, Salesforce will set the first contact in that email as the primary and it will be the only contact that will have LastActivityDate populated. All others will not since they are not primary. I'm specifically talking about standard LastActivityDate that is typically hidden. I need this for a report to see when a contact had last activity (not looking for all activities, just when the last one happened). 
I reached out to Salesforce and they said this is standard functionality and couldn't provide a workaround.

Can anyone help me to at least point me in the right direction? I've tried many different things, but it seems like my only solution is code. I'm not that familiar with code, so if that's the case, the more details you can provide the better.

Thank you for your help.
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.