Skip to main content
2 of 5
added 247 characters in body
sfdcJameson
  • 1.1k
  • 12
  • 23

Revised Answer:

Heres what I would do if I were you

Trigger

trigger TestTaskTrigger on Task (after insert) {
       if(trigger.isInsert && trigger.isAfter){
            Task_Methods.setWhat(trigger.new);
        }
}

Class

public class Task_Methods{
    public static void setWhat(List<Task> newList){
        for(Task t : [SELECT Who.AccountId FROM Task WHERE Id IN :newList AND WhoId != null AND Who.type = 'Contact']){
            t.WhatId = t.who.AccountId;
        }
    }
}
sfdcJameson
  • 1.1k
  • 12
  • 23