+ Start a Discussion
CyberfireCyberfire 

Workflow to close tasks generated by workflow - vicious circle?

I'm attempting to simplify basic tasks for users, and here is what I am trying to do:

 

3 checkbox's, and when you check the first one, it logs 2 completed activities, sends an email, and generates a new tasks (status is not started) 2 hours later.

 

The problem is, I want a second checkbox that does this:  close the open task that the first workflow created, and then create a new open task.

 

Since you can't create cross-object workflows, I'm not sure if this is even possible.  I've been trying to figure out a good solution, but I think I'm up against a brick wall here.

 

Can apex do something like this?

werewolfwerewolf
Yes, you can do that with an Apex trigger on Activity (a Task is a type of Activity).
CyberfireCyberfire

How would I go about doing that? Some how triggering off of checkbox 2 = true and going from there? I'm a complete newb with apex triggers, but it seems like to do this fancy stuff you need to know it.

 

 

werewolfwerewolf

Well, off the top of my head the steps would be (in an Activity before update trigger):

 

1.  Look at what's in Trigger.new, get Checkbox2__c for each task, and see if it's true and has changed from the corresponding Trigger.old.

2.  If it has, change the Trigger.new object's status to a closed status, and make a new task.

 

Yes, now would be a good time to learn Apex then.  You might want to check out the development books section in the getting started tab above, or download the force.com cookbook for code samples.