I have a trigger that updates a field on Contact when an email is sent to the contact. The trigger fires just fine if the user clicks the send email button on the Contact detail page. However, if the user sends the email from Outlook, the WhoId is null and the trigger does not fire. The weird thing is that I can offload the task data using Dataloader and the WhoId is in the Task record. Happy to post code if anyone wants to see it.

  • 2
    The WhoId is updated asynchronously, not upon initial creation. This has to do with the automatic association feature of Salesforce for Outlook. You'll probably want to write a "future" method to handle those cases.
    – sfdcfox
    Nov 30, 2017 at 20:14
  • That is brilliant and I had no idea. Thanks so much for that sweet little tidbit. Nov 30, 2017 at 20:30
  • Yeah, I remember this tripping me up some time ago, too. Try it out and let me know if that helped out.
    – sfdcfox
    Nov 30, 2017 at 20:42
  • you may want to consider putting that in a qeueable as well if you have any batch processes that may cause your trigger to execute - it would bomb with a future method in there - would get the same benefits with a more flexible use case.
    – Ronnie
    Dec 1, 2017 at 3:43
  • At the moment, I dont see a scenario where there would be more than one update as it happens when someone sends an email to a contact. I suppose if I uploaded a few hundred tasks that were completed emails using Dataloader it would blow up but I dont see that happening. Good defensive thinking though and I appreciate the comment. Dec 1, 2017 at 17:24


You must log in to answer this question.

Browse other questions tagged .