• B E N S.ax1881
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hello all.  We have a trigger on the Task object that looks at the WhatId and/or WhoId to update certain fields on the related Account.  A user reported an issue to us when adding emails to Account and Contact records.  Upon taking a look at the debug logs, the WhatId and WhoId are both NULL in Before and After triggers.  However, after the Task record is saved, the WhatId and WhoId are properly set.  The logic of the trigger does not execute properly since the values are NULL when the trigger is executing.  Even if I perform a query in the After trigger for the WhatId and WhoId, they are still NULL.

 

How does Salesforce for Outlook work regarding the WhatId and WhoId?

 

System.debug commands:

	for (Task record : Trigger.new) {
		System.debug(record.WhoId);
		System.debug(record.WhatId);
		System.debug(record.Status);
		System.debug([SELECT Id, WhoId FROM Task WHERE Id = :record.Id].WhoId);

 Result in debug log:

15:26:09.682 (682782000)|USER_DEBUG|[13]|DEBUG|null
15:26:09.682 (682788000)|SYSTEM_METHOD_EXIT|[13]|System.debug(ANY)
15:26:09.682 (682839000)|SYSTEM_METHOD_ENTRY|[14]|System.debug(ANY)
15:26:09.682 (682850000)|USER_DEBUG|[14]|DEBUG|null
15:26:09.682 (682856000)|SYSTEM_METHOD_EXIT|[14]|System.debug(ANY)
15:26:09.682 (682940000)|SYSTEM_METHOD_ENTRY|[15]|System.debug(ANY)
15:26:09.682 (682953000)|USER_DEBUG|[15]|DEBUG|Completed
15:26:09.682 (682959000)|SYSTEM_METHOD_EXIT|[15]|System.debug(ANY)
15:26:09.683 (683169000)|SOQL_EXECUTE_BEGIN|[16]|Aggregations:0|select Id, WhoId from Task where Id = :tmpVar1
15:26:09.700 (700279000)|SOQL_EXECUTE_END|[16]|Rows:1
15:26:09.700 (700390000)|SYSTEM_METHOD_ENTRY|[16]|System.debug(ANY)
15:26:09.700 (700398000)|USER_DEBUG|[16]|DEBUG|null