How can I set the id of an Omnifocus task in my AppleScript?

Hello, the following code gets an
application error and I don’t know why? The OmniFocus Applescript dictionary says the id is a settable attribute. I suspect I don’t understand variable scoping or something in Applescript. :-). Thanks for any help

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "OmniFocus"
	tell default document
		set theTask to (make new inbox task with properties {name:"Test Name", note:"Tra la la"})
		set id of theTask to "testing" -- this fails, why?
	end tell
end tell

Here is the error

And this variation fails in a different way:

				tell theTask
					set id to (string tHash) -- why does this fail?  
				end tell

And of course, this code works fine:

if tDate ≠ "" then
    set due date of theTask to tDate
end if

Thank you for your help.

I think, in practice, that that might just be a typo in the SDEF.

Not sure what you are aiming for, but there are probably other routes.

I’m looking to create a unique identifier that links the task between Omnifocus and another application. This identifier is known to me at time of creation, and its name is tHash. The id field naturally occurred to me as a good place for this. But if as you say the docs are wrong, I’ll just find another way. It would be good to hear Omni confirm this

Confirmed by Omnifocus support: their dictionary documentation is wrong about this. The ‘id’ attribute is not settable. Hopefully it gets corrected in the next set of docs.

1 Like