I have a trigger to feed to Chatter Event activities. It predates Salesforce's chattering of activites and I'd like to keep it.

It works when I use the manual web interface. Upon investigating debugs now the WhatId is blank during the trigger run but when I pull the event later in the Excel Connector, the WhatId is not blank - it has been associated.

The trigger runs after insert and associates via the field WhatId - what I need to use. AccountId field is also blank during the trigger run.

Any suggestions? Do I need to run a batch after this, later than the 'after insert"? How can the event be inserted and associated but return a null WhatId?

2 Answers 2


The workaround is to have the trigger check to see if WhoId and WhatId were both NULL. If so, the trigger would pass the event Ids to an @future method that would then check to see if WhoId or WhatId was populated and perform logic.


  • Can you assist with my @future method? I am getting null pointer exceptions on odd lines, one on a system.debug line
    – jaw999
    Jan 15, 2014 at 19:23
  • Need to see code? Jan 16, 2014 at 0:11
  • Thank you for posting the workaround. I'm having the issue of having null WhoId on the Task record. The flow of action is as follows: Outlook "Add Email" --> Standard Task creation --> Task trigger --> Apex code @future method My Task trigger calls a @future method in an Apex class. I'm seeing the null WhoId in the Apex @future method, not in the trigger itself. So I'm not sure how your proposed workaround works in this scenario. What happens if the WhoId and WhatId are still detected null in the @future method? Do you have a loop that keeps calling the @future method with the Task a
    – user16531
    Jan 21, 2015 at 3:41


I just discovered the same issue and I think I can help you out.

Basically you need your trigger to determine whether the who and what Id are null - NOT your apex class.


trigger TaskTrigger on Task (after insert, after update) {
    if (trigger.isAfter && TriggerHandler.firstRunTaskAfterTrigger) {
        //On After Insert 
        if(trigger.isInsert) {
            Set<Id> tasksWithBlankWhoAndWhatId = new Set<Id>();

            for (Task task : trigger.new) {             
                if(trigger.newMap.get(task.Id).WhoId == null && trigger.newMap.get(task.Id).WhatId == null)

            try {

            catch (Exception e) {
                for (Task task : trigger.new) {
                    system.debug('after insert error: ' + e.getMessage());

Then your class should have a method like this:

public with sharing class TaskUpdateActivityInfo {      
    public static void determineObjTypeSFO(Set<Id> taskIdsForProcessing) {
        //Do Stuff

Hope this helps.

You must log in to answer this question.

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