Deep thought 💭 on Delegated.scpt

I have been using Delegated.scpt, an Applescript developed by Guillaume Cerquant, in my OmniFocus setup for years. I have even developed Applescripts that utilize it. Sadly, it appears as though Guillame’s website has gone offline. I have put it out on Github (with a minor modification of my own), and I am posting it here:

(*
Delegated - V1.2 - 9th, may 2008
This script duplicates the selected task to a WFor context, and mark the selected as completed
Use case: When completing a task by delegating it to someone, and waiting for its completion
Eg:
You've just finished the task "Mail Bob about contracts to buy some land on the Moon - Great opportunity: don't miss it"
and are waiting for Bob's opinion.
Select the task, and execute this script
=> it will duplicate the task into the WFor context, and mark the original one as completed
HOW TO USE
Edit the settings in the configuration part of this script
UPDATE
You can find updates at: http://www.cerquant.com/software
FEEDBACK
I would love to get feedback on this script. I really do.
Please contact me to tell me what you think about it, what you want in next versions, what's wrong...
AUTHOR
Guillaume Cerquant - gcerquant@gmail.com
Copyright © 2007, Guillaume Cerquant
LICENSE 
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CHANGELOG
v1.0: First release
v1.1:
Add a prefix to the title of the task created in WFor
If no document is open, open one
Growl notification
Warns users if the task selected isn't a leaf
v1.2:
Option to reset the due date
Warning when trying to delegate an inbox task
TODO        Set the start date
TODO Duplicate just after the current task
THANK YOU
Tim Wood from Omni, Curt Clifton, Sandro Pugliese and all users who gave feedback.
TODO:
? Handle the selection of several tasks
? Duplicate just after
? Project / Folder name => Association
*)
-- CONFIGURATION
-- Edit this line with the name of your Waiting-For context ; The task duplicated will be moved in this context.
property WForContext : "Waiting"
-- Edit this line with the value of the string that will be prefixed to the title of the created task in WFor 
-- If you don't want the title to be prefixed, edit the line like this: property thePrefix : ""
property thePrefix : "Waiting For: "
-- Copy the due date of the delegated task on the created task?
property copyTheDueDate : true
property theStartDate : "05/12/07"
-- Set to false if you don't want any growl notification
property useGrowl : true
-- END OF CONFIGURATION (Nothing to edit past this line!)
-- Growl properties
property growlAppName : "Guillaume's Scripts"
property delegatedNotification : "Delegated script"
property defaultNotifications : {delegatedNotification}
property allNotifications : {delegatedNotification}
property iconLoaningApplication : "OmniFocus.app"
property growlVerboseLevel : 1
tell application "OmniFocus"
-- If no document is open, open one
tell default document
if number of document window is 0 then
make new document window with properties {bounds:{0, 0, 500, 500}}
end if
end tell
-- Check one and only one task is selected
tell front document
tell (first document window whose index is 1)
set theSelectedItems to selected trees of content
if ((count of theSelectedItems) < 1) then
display alert "You must first select a single task." message "Select a single task before running this script." as warning
return
end if
if ((count of theSelectedItems) > 1) then
display alert "You must select only one task." message "Select a single task before running this script." as warning
return
end if
end tell
end tell
set theSelectedTask to value of item 1 of theSelectedItems
if theSelectedTask is in inbox then
display alert "You can't delegate a task still in the inbox." message "Process the task into a project before running this script." as warning
return
end if
set MyDoc to first document
tell MyDoc
if (WForContext is "") then
my wrongContextError()
else
set contextList to complete WForContext as context maximum matches 1
if (contextList is {}) then
my wrongContextError()
else
set theWForContext to context id (id of item 1 of contextList)
end if
end if
end tell
-- Warns users if the task is not a leaf
if (tasks of theSelectedTask is not {}) then
if button returned of (display dialog "The task you selected for delegation has sub-tasks.rThe task and its subtasks will be duplicated and marked as completed, however, only the context of the root task will be set to the context '" & WForContext & "'." buttons {"Cancel the delegation", "Continue"} default button 1 with icon 1) is equal to "Cancel the delegation" then
-- If user wisely canceled, exit the script           
error number -128
end if
end if
display dialog "Who should be followed up with?" default answer "Someone" buttons {"Cancel", "OK"} default button 2
set delegated to (the text returned of the result) as string
display dialog "When should be " & delegated & " be followed up with?" default answer "1/1/2099 8:00 AM" buttons {"Cancel", "OK"} default button 2
set delegateddue to (the text returned of the result)
set delegatedduedate to (delegateddue as string)
if (not copyTheDueDate) then
set due date of theDuplicatedTask to delegateddue
end if
-- set start date of theSelectedTask to theStartDate
set FollowUpTask to the name of theSelectedTask
set FollowUpTask to "Follow Up with " & delegated & " re: " & FollowUpTask
set theDuplicatedTask to duplicate theSelectedTask to end of tasks of containing project of theSelectedTask with properties {name:FollowUpTask, context:theWForContext}
set due date of theDuplicatedTask to date (delegatedduedate as string)
set completed of theSelectedTask to true
end tell
--  Uses Growl to display a notification message.
on growlNotify(theTitle, theDescription, theNotificationKind, errorLevel)
if (useGrowl) then
if (errorLevel ≤ growlVerboseLevel) then
tell application "Growl"
«event register» given «class appl»:growlAppName, «class anot»:allNotifications, «class dnot»:defaultNotifications, «class iapp»:iconLoaningApplication
«event notifygr» given «class name»:theNotificationKind, «class titl»:theTitle, «class appl»:growlAppName, «class desc»:theDescription
end tell
end if
end if
end growlNotify
-- Display error and quit
on wrongContextError()
display alert WForContext & " context not found" message "Your waiting-for context: '" & WForContext & "' wasn't found.rPlease edit the line 'property WForContext' of the script."
-- Exit the script
error number -128
end wrongContextError
Published: Aug 10, 2014 @jeredb →