Hmm, thanks for the fast answer - this isn't producing an error in Hazel, but it doesn't create a task at all. Don't know if there is a way (for me) to see where it stucks or what it's actually doing.
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!
|
|
FAQ | Members List | Calendar | Today's Posts | Search |
Adjusting of AppleScript to add project, context and start date | Thread Tools | Search this Thread | Display Modes |
|
Member
2013-05-29, 03:07 AM
Hmm, thanks for the fast answer - this isn't producing an error in Hazel, but it doesn't create a task at all. Don't know if there is a way (for me) to see where it stucks or what it's actually doing.
Post 1
|
Guest
2013-05-29, 04:01 AM
Note that the code doesn't aim to create a task in the inbox – it should be placing it directly under the project.
Post 2
|
Member
2013-05-29, 06:08 AM
yeah, i got that, but actually it isn't adding a task at all, not in the inbox, not in the project... :(
Post 3
|
Member
2013-05-29, 10:41 AM
I know this is not a full solution, but I thought you might be interested in two associated articles and scripts for creating tasks in OmniFocus via Hazel.
The first is the original David Sparks script. From this blog post http://macsparky.com/blog/2012/8/app...mnifocus-tasks Code:
-- Lovingly crafted by David Sparks, The Omni Group, and Ben Waldie -- macsparky.com set theDate to current date set theTask to "Pay Life Insurance" set theNote to "Lovingly Scanned by your Mac on " & (theDate as string) tell application "OmniFocus" tell front document set theContext to first flattened context where its name = "Tech" set theProject to first flattened project where its name = "Finance" tell theProject to make new task with properties {name:theTask, note:theNote, context:theContext} end tell end tell Code:
tell application "Finder" to set file_name to (name of theFile) tell application "OmniFocus" set task_title to "Pay " & file_name tell default document set newTask to make new inbox task with properties {name:task_title} tell the note of newTask make new file attachment with properties {file name:theFile, embedded:false} end tell end tell end tell Code:
tell application "Finder" to set file_name to (name of theFile) tell application "OmniFocus" set task_title to "Pay " & file_name tell default document set theContext to first flattened context where its name = "iMac" set newTask to make new inbox task with properties {name:task_title, context:theContext} tell the note of newTask make new file attachment with properties {file name:theFile, embedded:false} end tell end tell end tell To get the obvious out of the way — yes, I did replace the "make new inbox task" with "make new task" when testing this with a line similar to Code:
set theProject to first flattened project where its name = "Finance" Thank you in advance.
Post 4
|
Member
2013-05-30, 02:39 AM
Quote:
thanks for sharing this. I've tried this one but it's not doing anything to my OmniFocus. I'm wondering if this could be because I have a german OSX?
Post 5
|
Member
2013-05-30, 12:38 PM
I am not sure if your language setting would be affecting these scripts. I had many versions of the script silently fail within Hazel because of simple errors in the script itself. Check first that you modified "iMac" in my script from above to a context you currently have in your OmniFocus. It is not clear if you used the following line in your script or not.
Code:
set theProject to first flattened project where its name = "Finance" Does the script work? If the script is not working, could you test the David Sparks script and the Patrick Lens script? 1. Create a folder on you desktop named "Test" and add it to Hazel. 2. Create a rule for the folder "Test" to run if a file named "sparks.txt" is added to the folder — have this rule run the David Sparks script. 3. Create another rule for the folder "Test" to run if a file named "lens.txt" is added to the folder — have this rule run the Patrick Lens script. Please post your results. Did my modified script run? Did the David Sparks script run? Did the Patrick Lens script run? Thank you.
Post 6
|
Member
2013-05-30, 09:11 PM
Hi Dale,
thanks for that help. After putting all scripts ones after ones your's worked well - I found that i did a copy error and missed the first line. BTW: I've edited your script a little bit to add the date of the scan (stole that at asianeffiecncy): Code:
tell application "Finder" to set file_name to (name of theFile) set theDate to current date set theNote to "Scanned " & (theDate as string) & " " tell application "OmniFocus" set task_title to "Proceed: " & file_name tell default document set theContext to first flattened context where its name = "Review" set newTask to make new inbox task with properties {name:task_title, context:theContext} set note of newTask to theNote tell the note of newTask make new file attachment with properties {file name:theFile, embedded:false} end tell end tell end tell
Post 7
|