Delete child tasks from duplicated task

Background
My process for managing tasks based on emails is as follows:

  1. creating actions from emails
  2. creating sub-actions for actual work (which turns the email action into an Action Group)
  3. marking the sub-actions as completed
  4. replying to the original email
  5. marking the original email as completed and awaiting reply (using Curt Clifton’s Complete and Await Reply script)

Issue
Everything works fine except that the Waiting For task inherits the child tasks of the original task. I’ve tried to modify Curt’s script to delete the children based on other script examples but I keep getting an error when the script runs.

Script Snippet

repeat with childTask in theDupe's tasks
    delete childTask
end repeat

I have added this at the end of the repeat with anItem in theSelectedItems loop.

The Error

The operation couldn’t be completed. /Users/matt/Library/Application Scripts/com.omnigroup.OmniFocus2.MacAppStore/Complete and Await Reply.scpt: execution error: OmniFocus got an error: Unable to delete 1 of the specified objects. (6)

The Ask
Can anyone tell me what’s wrong with my delete task code snippet?

I’m not able to correct your AppleScript, but I would suggest a slight modification to your workflow which would allow the script to work out of the box.

As I understand it, you get an email from Jerry who asks for 3 deliverables. You then create the following action group:

##Random Project

  • Respond to Jerry’s email
    • Complete Jerry’s #1 deliverable
    • Complete Jerry’s #2 deliverable
    • Complete Jerry’s #3 deliverable

Because each of the requested deliverables requires one or more actions on your part, you fill out the action group like so:

##Random Project

  • Respond to Jerry’s email
    • Complete Jerry’s #1 deliverable
      • My action #1
      • My action #2
    • Complete Jerry’s #2 deliverable
      • My action #1
      • My action #2
    • Complete Jerry’s #3 deliverable
      • My action #1
      • My action #2

You then complete the “My actions” which completes the “Jerry’s deliverables.” After responding to the email, you run Curt’s script, which completes the “Respond to Jerry’s email” action group but duplicates it (with sub-actions) as a waiting for.

My suggestion would be to structure the action group like this:

##Random Project

  • Respond to Jerry’s request
    • Complete Jerry’s #1 deliverable
      • My action #1
      • My action #2
    • Complete Jerry’s #2 deliverable
      • My action #1
      • My action #2
    • Complete Jerry’s #3 deliverable
      • My action #1
      • My action #2
    • Respond to Jerry’s email

This last task is the one to which you apply Curt’s script. That way, it has no sub-actions, and if you mark the “Respond to Jerry’s request” action group as a parallel action group, you could even have other email chains in this one, such as “Request help from Jane to complete Jerry’s #3,” running Curt’s script on any or all of those.

1 Like