I have created a new task with the following code (works successfully):
set actionTitle to theTitle & " (Kopie)" & "@" & theContext & "::" & theProject
set newTask to (parse tasks into it with transport text actionTitle)
log(newTask)
The result is: (task id kBCbFXSVOsZ of document id eIPIxagwE6w). And then I want to set the defer date of this task to a certain date, but this line doesn’t work:
set the defer date of newTask to theDeferDate
I get this error:
error “„«class FCDs» of {«class FCac» id “dSFgclR9X1n” of document id “eIPIxagwE6w” of application “OmniFocus”}“ can not be set as „date “Sunday, 17. January 2016 at 00:00:00”“.” number -10006 from «class FCDs» of {«class FCac» id “dSFgclR9X1n” of document id “eIPIxagwE6w”}
tell first document window of front document
set SelectedItemInMainView to selected trees of content
set selectedTask to value of item 1 of SelectedItemInMainView
end tell
tell default document
set theDeferDate to get defer date of the selectedTask
end tell
parse tasks into returns a list of the created tasks. In order to access of modify the properties of the newly created task you need to address the task itself.
try
set newTask to first item of (parse tasks into it with transport text actionTitle)
the rest of your script should then work as expected. – Sven.