I am having a hard time finding an example of simply updating and inbox action. All I want to do is select an Action or Actions in the inbox and update the Action(s) Project and Context to a pre configured Project and Context that I have specified. Sounds simple enough. Any ideas on this?
Had a similar question, and figured out how to update task properties… but not sure how to set the context. The script below works for setting the context, but for some reason it doesn’t like to set the project.
on run
set thePerspective to "Inbox"
set theContextName to "My Context"
set theProjectName to "My Project"
tell application "OmniFocus"
tell front document
set theProject to first flattened project where name = theProjectName
log theProject # For debugging
set theContext to first flattened context where its name = theContextName
tell (first document window whose index is 1)
set perspective name to "Inbox"
set theSelectedTasks to trees of content
set numTasks to (count items of theSelectedTasks)
set selectNum to numTasks
repeat while selectNum > 0
set selectedTask to value of item selectNum of theSelectedTasks
set taskName to get name of selectedTask
set the context of the selectedTask to theContext
set the containing project of the selectedTask to theProject
set selectNum to selectNum - 1
end repeat
end tell
end tell
end tell
end run
Some other links to check out -
http://forums.omnigroup.com/showthread.php?t=29790
http://bylr.net/files/omnifocus/
Thanks! Let me try this out and see if I can get something to work around context. I think I might know hot to make it work.
I figured it out, please see below:
set thePerspective to "Inbox"
set theContextName to "Do"
set theProjectName to "My Actions"
tell application "OmniFocus"
tell front document
set theProject to first flattened project where name = theProjectName
log theProject -- For debugging
set theContext to first flattened context where its name = theContextName
log theContext -- For debugging
end tell
tell first document window of front document
--set perspective name to "Inbox"
set validSelectedItemsList to selected trees of content
set totalItems to count of validSelectedItemsList
if totalItems is 0 then
set alertText to "No valid task(s) selected"
my Notify(alertText)
end if
repeat while totalItems > 0
set selectedTask to value of item totalItems of validSelectedItemsList
set taskName to get name of selectedTask
log "TASK-NAME: " & taskName -- For debugging
set the context of the selectedTask to theContext
set the assigned container of the selectedTask to theProject
set totalItems to totalItems - 1
end repeat
end tell
end tell