View Single Post
Curt:
Quote:
Originally Posted by curt.clifton View Post
What do you mean by "future" OmniFocusInboxTask?
The object created by the code above, is described by PyObjC like this:
<future OmniFocusInboxTask with properties { name = "Task name"; }>
I suspect that "future" may be ScriptingBridge's way to indicate that the apple event to create the object is not yet sent. But that's just a theory.


Wim:
Quote:
My other thought is that you might have to insert the newly created object into a container before it becomes real
I think you are right about this. I've tested recreating the code in F-script, and the error message I get there is "object has not been added to a container yet".

But how do I assign it to a container?

In OmniFocus applescript dictionary I found this:
assigned container (item) : Inbox tasks (those contained directly by the document) have a provisionally set container that is made final by the 'compact' command. This allows you to set and get said container. The container must be either a task (not in the inbox or contained by an inbox task), a project or 'missing value'.
But despite trying a lot of different aproaches, I've not been able to make it work.

I'm not 100% sure, but the problem seams to be that
omnifocus.classForScriptingClass_('inbox task').alloc().initWithProperties_({'name': 'Computer created task'})
results in a object that is a ScriptingBridge proxy object. This object as such is unable to respond to messages like compact(), setAssignedContainer_() and addObject_(). Normaly, this would be easy to solve by adding a get(), to get the real object, but for some reason this results in an error.

Maybe it's a cache 22-like bug: To attach the object to a container you need to send a get to it, but since it's not attatched to any container this is not possible....

Another, equally likely, possibility is that I haven't got the sytax quite right.

If anyone has managed to create a new task in OmniFocus, using Objective C, Python, F-script or Ruby, it would be extremely interesting to see the code.

Until then, I might try the applescript in Python workaround Wim suggested.

Last edited by Tommy@heltenkelt.se; 2008-08-01 at 12:17 PM..