Quote:
Originally Posted by RobTrew
It seems that Applescript code embedded in Hazel can't use function definitions (Hazel probably wraps the code in a function handler).
You should be able to unpackage the functions along these lines:
Code:
tell application "Finder" to set file_name to (name of theFile)
set theDate to current date
set theNote to "Scanned " & (theDate as string) & "
"
set projectname to "Proceed Files"
set ContextName to "Some Context"
set theTask to "Proceed: \"" & file_name & "\""
tell application "OmniFocus"
set task_title to theTask
tell default document
-- GET A REFERENCE TO AN EXISTING PROJECT (OR NEW) PROJECT
set lstProj to flattened projects where name = projectname
if lstProj ≠ {} then
set oProj to item 1 of lstProj
else
set oProj to (make new project with properties {name:projectname})
end if
-- GET A REFERENCE TO AN EXISTING (OR NEW) CONTEXT
set lstContexts to flattened contexts where name = ContextName
if lstContexts ≠ {} then
set oContext to item 1 of lstContexts
else
set oContext to (make new context with properties {name:ContextName})
end if
-- MAKE A NEW TASK UNDER THE SPECIFIED PROJECT, ATTACHING IT TO THE SPECIFIED CONTEXT
tell oProj
tell (make new task with properties {name:task_title, context:oContext})
set its note to theNote
tell its note to make new file attachment with properties {file name:file_name, embedded:false}
end tell
end tell
end tell
end tell
|
I have to admit that I'm really stupid. This script works like a charm if you copy it right. I forgot the first line again... Sorry for beeing so dumb!
Just one more question: Can you help me to add a Start Date for that task as well? I'd like something like "today+3".
Cheers,
Ben
PS: Rob you are truly a hero!