+ Start a Discussion
Paul.FoxPaul.Fox 

Action Plans - Task Field Update causes duplicate dependant tasks

I installed Action Plans and got it set up for one of my custom objects. However, when I marked off a task, it was creating two dependant tasks. I looked at the debug log and it turns out that I had a field update on the task object which was causing the task trigger to run again, creating a second dependant task.

 

Luckily, I just had this problem with some other apex code, so here's what I did:

 

In the ActionPlansTaskTriggerUtilities class I added:

 

public static boolean firstTrigger = true;

In the ActionPlanTaskTrigger I wrapped everything inside of an if statement:

 

if(    ActionPlansTaskTriggerUtilities.firstTrigger == true){
        ActionPlansTaskTriggerUtilities.firstTrigger = false;
      // Existing code went here
}

 

This appears to be working correctly. Let me know if this will mess anything else up.

 

 

ReidCReidC

Great info!  Thanks for posting it.

Pettycash73Pettycash73

We downloaded the Action Plan app for use with our Lead process.  The idea is that there are 4 steps to each action plan as it relates to the selling of our leads. If the Lead is unqualified at any point, the action plan continues to think that the next steps need be taken, which they don't.  

 

We are using dependent tasks, so that when step 1 is completed, the next action is set automatically for 7 days from today.  If the lead is unqualified at step 1, when the task is marked as completed, step 2 is triggered, unnecessarily.

 

Is there any logic that can be built to kill an action plan based when criteria is met? In this case, if the lead status is changed to Unqualified than the action plan should be stopped.

 

Open to any ideas.

Paul.FoxPaul.Fox

You could modify the Task Trigger that comes with the package to check the Lead Status before creating the next task. The actual code may be in the Task Trigger Utilities Apex Class

Pettycash73Pettycash73

Thanks for the idea. I am not up to speed on writing triggers or modifying them for that matter.

 

We will move forward with the delete option, with the hope that in future version there will be criteria based options available for Action Plans.