View Single Post
I've updated your AppleScript below. I had to capture the context by using the line:

set theContext to the context "Online"

This gets the context's ID and passes it to the selected items in the script.

Next I changed due date from "today" to "current date", AppleScript's term for getting today.

I've also added a test to see if the selected item is a project by trapping for a parent task. I don't know if that's the correct way to test an item for being a project but it's all I could come up with for now.

Anyway, it works fine in my OmniFocus, you may want to do some testing with various projects to make sure.


tell application "OmniFocus"
tell front document
set theContext to the context "Online"

-- Gets target context
tell content of document window 1 -- (first document window whose index is 1)
set theSelectedItems to value of every selected tree
if ((count of theSelectedItems) < 1) then
display alert "You must first select an item to complete." as warning
return
end if
repeat with anItem in theSelectedItems
if parent task of anItem = missing value then
set name of anItem to "AP, AR, Finance"
set context of anItem to theContext
-- set properties of anItem to {context:ActionContext}
else
set context of anItem to theContext
set due date of anItem to current date
end if
end repeat
end tell
end tell
end tell