3

When our users leverage the email-to-saleforce feature that allows them to bcc emails to salesforce, those emails are added as Tasks of type 'Email' in the Activity History related list for relevant Contacts, Accounts, Leads, and Opportunities.

I have a trigger that processes Tasks of type 'Email' based on the whatIds associated with the Task. Unfortunately, the whatIds for tasks coming from email-to-salesforce distro have a null whatId and whoId even though they show on the Activity History related list.

Has anyone run into this before? Can anyone recommend a fix?

EDIT

I'm working with Accounts. Here is a System.debug dump of the task object that is created and associated to the Account when email-to-salesforce is used. Note that the whoId and whatId are both null even though the Task shows up in the related list.

18:40:22:465 USER_DEBUG [24]|DEBUG|{null=Task:{LastModifiedDate=2015-05-29 22:40:22, CallDisposition=null, ActivityDate=2015-05-29 00:00:00, IsClosed=true, WhoCount=0, RecurrenceTimeZoneSidKey=null, RecurrenceInstance=null, RecurrenceType=null, IsHighPriority=false, CallType=null, Activity_Type__c=null, Tasking_Date__c=null, IsArchived=false, CallObject=null, RecurrenceEndDateOnly=null, RecurrenceMonthOfYear=null, AccountId=null, CreatedById=005i0000003Tu6yAAC, IsDeleted=false, Id=00T19000003AJPAEA4, CS_Contact_Date__c=null, RecurrenceStartDateOnly=null, RecurrenceDayOfMonth=null, Type=Email, OwnerId=005i0000003Tu5yABC, RecurrenceRegeneratedType=null, IsRecurrence=false, IsReminderSet=false, WhoId=null, SystemModstamp=2015-05-29 22:40:22, WhatCount=0, Description=Additional To: [email protected]

2 Answers 2

1

I am also faced that same issue when a task is created Using Email To Salesforce.

So to fix the issue I moved my trigger code that is doing some operation on the basis of AccountId into a future method.

So now, whenever a task is created and WhatId, WhoId, or Account Id is blank, I am calling a future method from trigger .

See here to get more information regarding future methods :https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm

0

Which object's Activity History related list are you referring to? It sounds like Opportunity is not being set on these tasks.

AccountId is it's own Activity field but it's not exposed on the page layout. AccountId is inherited from the parent of the WhatId when it is a Case or Opportunity or the WhoId when it is a Contact.

Perhaps look at WhoId or AccountId instead?

3
  • post edited with additional details. Commented Jun 1, 2015 at 10:55
  • ok - so what related list do these tasks show up on?
    – RyanP
    Commented Jun 1, 2015 at 18:21
  • They show up on the Accounts -> Activity History and the Contacts -> Activity History Commented Jun 3, 2015 at 13:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .