Hi there,
I am really new to AppleScript and I am completely stumped on how to set the due date for Tuesday (preferably at 1pm). This is what I’ve tried so far…
set theTask to "Read CLLM workshop notes"
set dueDate to "Tuesday"
tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "Reading"
set theProject to first flattened project where its name = "LLAW1212 Criminal Law"
tell theProject to make new task with properties {name:theTask, context:theContext, due date:dueDate}
end tell
end tell
This returns the error message:
error “OmniFocus got an error: Can’t make “Tuesday” into type date or missing value.” number -1700 from “Tuesday”
I am wanting to use this script with Hazel, in case that changes anything.
Any help would be gratefully appreciated!
Thank you in advance.
Aaron
Others can jump in and take away my sledgehammer if there is a more elegant way. I cannot figure out how to simply set a day of the week as a due date either. Here goes nothin’!
set theTask to "Read CLLM workshop notes"
tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "Reading"
set theProject to first flattened project where its name = "LLAW1212 Criminal Law"
tell theProject
set theAction to make task with properties {name:theTask, context:theContext}
set timestamp to current date
if weekday of timestamp is Tuesday then
set dueDate to timestamp + 7 * days
else if weekday of timestamp is Wednesday then
set dueDate to timestamp + 6 * days
else if weekday of timestamp is Thursday then
set dueDate to timestamp + 5 * days
else if weekday of timestamp is Friday then
set dueDate to timestamp + 4 * days
else if weekday of timestamp is Saturday then
set dueDate to timestamp + 3 * days
else if weekday of timestamp is Sunday then
set dueDate to timestamp + 2 * days
else if weekday of timestamp is Monday then
set dueDate to timestamp + 1 * days
end if
set due date of theAction to dueDate
end tell
end tell
end tell
Thank you so much TheWart - although it may be the sledgehammer solution, it worked! I’m just relieved it wasn’t a super easy solution that I completely overlooked.
Thanks again!