The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Adding an attachment to a task created with AppleScript via Hazel (http://forums.omnigroup.com/showthread.php?t=28585)

HirnHorn 2013-03-05 11:54 PM

Adding an attachment to a task created with AppleScript via Hazel
 
Hey,

[COLOR="Silver"]I use this great embedded AppleScript as part of my Hazel workflow for scanned documents.

I'd like to attach the document to the Omnifocus-task. Can somebody show me how?

---------------------------

-- Lovingly crafted by David Sparks, The Omni Group, and Ben Waldie --

set theDate to current date
set theTask to "whatever I need"
set theNote to "whatever extra information I need " & (theDate as string)

tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "Internet"
set theProject to first flattened project where its name = "Single Actions"
tell theProject to make new task with properties {name:theTask, note:theNote, context:theContext, due date:theDate}
end tell
end tell
end tell

-------------------------[/COLOR]

Ok, just incase anybody stumbles across this post, I got it running. Now my script looks like this:

-------------------------

set theDate to current date
set theDueDate to current date
set theTask to "whatever"


tell application "Finder" to set file_name to (name of theFile)
tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "nameofthecontextIneed"
set NewTask to make new inbox task with properties {name:theTask, context:theContext, due date:theDate}
tell the note of NewTask
make new file attachment with properties {file name:theFile, embedded:true}
end tell
end tell
end tell

-------------------------

I still can't choose the project, although I must have tried a thousand possibilities, but I'm ok with this.


Thanks,

Chris


[COLOR="Silver"]Btw OmniFocus-Help tells me I can find AppleScript documentation in the AppleScript dictionary of OmniFocus, but I just can't find this dictionary. What am I missing?[/COLOR]
I found the AppleScript dictionary of Omnifocus. In Germany it's hidden in the AppleScript-Editor in Ablage -> Funktionsverzeichnis öffnen.


All times are GMT -8. The time now is 07:09 PM.

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