The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   AppleScript Documentation (http://forums.omnigroup.com/showthread.php?t=10902)

Michael Hyatt 2008-12-23 11:48 AM

AppleScript Documentation
 
I am wanting to add an Entourage message to OmniFocus. I have figured this out, thanks to this forum. I am using this code:

[CODE]tell application "Microsoft Entourage"

-- get the currently selected message or messages
set selectedMessages to current messages

repeat with theMessage in selectedMessages

-- parse the email(s)
set theName to subject of theMessage
set theContent to content of theMessage


tell application "OmniFocus"
set theContext to context "Waiting" of default document
set theTask to theName
set theNote to theContent

tell default document to make new inbox task with properties {name:theTask, note:theContent, context:theContext}
end tell

end repeat
end tell[/CODE]

However, I alo want to assign a specific project to the new task. How can I do that? I have searched the forum but can't find an answer.

Is there somewhere I can find complete documentation for OmniFocus' AppleScript interface?

Thanks.

whpalmer4 2008-12-23 11:55 AM

Have you looked at the OmniFocus dictionary in Script Editor?

[URL=http://imageshack.us][IMG]http://img72.imageshack.us/img72/2070/picture9rg6.png[/IMG][/URL]

Looks like you could set the assigned container (after looking it up) and tell the document to compact (appears to be what the Clean Up button does).

Michael Hyatt 2008-12-23 01:14 PM

This is a little over my head. Can you (or someone else) post a code snippet? Thanks.

schottac 2009-01-09 02:49 PM

Assigning a Project to an Inbox Task
 
Michael,
In case you haven't figured out how to do it yet, here's how I accomplished this:

[CODE]tell application "OmniFocus"
tell default document
set theProject to project "Follow Up"
set theContext to context "Online" of context "Mac" of context "Home"
set newTask to make new inbox task with properties {name:taskName, note:taskNote, context:theContext}
set assigned container of newTask to theProject

compact -- Clean up the task from the inbox since it has project and context
end tell
end tell[/CODE]

The key is the two lines after "set newTask". The first assigns it to the project represented by theProject, and the second is equivalent to pressing the "Clean Up" toolbar button within OmniFocus itself.

Hope this helps. :)

Andy

Michael Hyatt 2009-01-11 10:03 AM

Andy,

This is working beautifully! Thanks. I would have never figured it out on my own.

Mike


All times are GMT -8. The time now is 05:24 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.