I'm encountering some rather odd behavior when using the standard Log A Call button. Basically when creating tasks, I want to take some information from the task itself, and update the related contact.

The issue arises when a user logs a call using the standard button, and creates a follow up task at the same time. Everything works fine if no follow up task is scheduled at the same time, or if a follow up is scheduled in a separate transaction. However, if the user fills out both highlighted sections, I can't seem to access the task created in the red section.

If the green section is left empty, my code fires, and processes the red section as I would expect.

enter image description here


trigger TaskTrigger on Task (before insert, after insert, before update, after update, before delete, after delete) {
    if(Trigger.isInsert && Trigger.isBefore){
    else if(Trigger.isInsert && Trigger.isAfter){
    else if(Trigger.isUpdate && Trigger.isBefore){
    else if(Trigger.isUpdate && Trigger.isAfter){
    else if(Trigger.isDelete && Trigger.isBefore){
    else if(Trigger.isDelete && Trigger.isAfter){
    else if(Trigger.isUndelete && Trigger.isBefore){

Simplified Handler:

public class TaskTriggerHandler {
    public static void handleBeforeInsert(List<Task> newTasks) {



If a user fills out both the red and green sections, the task outlined in red doesn't appear in the debug message. I had thought that perhaps I was encountering an exception with both methods trying to update the same contact, but not getting an unhandled exception due to partial processing, but the debug logs confirm that the red-highlighted task is not even being processed by my code at all. Any ideas on what is going on here?

1 Answer 1


Not directly related to your question but I think it is important to reconsider your pattern:

the trigger code can be simplified to:

trigger TaskTrigger on Task (before insert, after insert, before update, after update, before delete, after delete) {

    TaskTriggerHandler.handleRecords(Trigger.newMap, trigger.oldMap, trigger.isInsert, trigger.isUpdate, trigger.isDelete, trigger.isbefore, trigger.isAfter);


then in your TaskTriggerHandler

public class TaskTriggerHandler{

      public static void handleRecords(Map<ID,Task> newMap, Map<ID,Task> oldMap, boolean isInsert, Boolean isUpdate, Boolean isDelete, Boolean isBefore, Boolean isAfter){
        //Pull out the List from the Map, use logic as necessary to use old vs new



once you do this it will be easier to debug and find out the exact issue.

  • Certainly possible to follow that pattern, but it really doesn't address my confusion. It would seem that two tasks are being inserted simultaneously, yet the debug log only shows one task in the before insert context. Jul 24, 2015 at 14:29
  • I would start by adding debugs through my code and following the trail int he debug log. The reason I posted the above it you have ALOT of opportunity for logic failures and what I suggested will reduce that giving you a clearer and easier picture of what is going on. Without the rest of your code ass we can say is one of your logic tests are returning false and thus not sending it through. Since they both work singly but not when done at the same time I think it is a logic problem
    – Eric
    Jul 24, 2015 at 14:33
  • Even if I simplify to trigger TaskTrigger on Task (before insert, after insert, before update, after update, before delete, after delete) { System.debug(trigger.new); } I still only see one task in the debug log. There is no logic being executed, so it cannot be a logic error. Jul 24, 2015 at 14:40
  • Then I am at a loss. If each work properly individually then that would seem to rule out a SF not firing trigger use case and thus it should work when both are filled out........
    – Eric
    Jul 24, 2015 at 15:14

You must log in to answer this question.

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