The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   AppleScript help: Create sub-task, project from task (http://forums.omnigroup.com/showthread.php?t=6052)

iNik 2007-12-04 08:55 AM

AppleScript help: Create sub-task, project from task
 
I'm fairly certain I'm missing something obvious here, but how do I create or duplicate a task so that it's within (as a subtask of) another task?

Also, is there an easy way, via AppleScript, to turn a task into a project (as though it were dragged from the task view to the projects sidebar)?

Thanks for the help!

iNik 2007-12-04 10:22 AM

Hrm... It appears that the only way to create a sub-task is to tell the parent task to create a new task. Not exactly intuitive, but it works. (I'd expect make new task at <parent task> to be the syntax.)

Then there's create a project from a task. I seem to have to do that by grabbing the properties of the task. No big deal, really. But what I'm trying to do is have a one-click way to take a task and turn it into a project with that same task within the project. (Specifically to take a singleton in a bucket and turn it into its own project as soon as it becomes clear it'll take more steps -- i.e. if it gains a "waiting" action)

What I can't seem to do is assign a task to a project, which seems entirely nutty.

Tim Wood 2007-12-04 08:40 PM

Creating a project from a task would ideally work by just creating a new project "with properties {root task:MyTask}", but this isn't specifically implemented -- it might work, but there would be a root task that would probably get orphaned and then resurrected into the Inbox ... not good. I've logged <bug://bugs/43714> ('make new project' should accept a 'root task' in its properties) on this.

Assigning a task to an inbox item would just involve setting the 'assigned container' (can either use a project, its root task or any other task). With an existing task, you should just 'move' it where you want it (TN2106 says container properties should generally be read-only and 'move' should be used to update them).

Here are some examples:

[code]
tell application "OmniFocus"
tell default document
set MyProject1 to make new project with properties {name:"Test project 1"}
tell MyProject1
set MyAction to make new task with properties {name:"action"}
end tell

set MyProject2 to make new project with properties {name:"Test project 2"}
move MyAction to end of tasks of MyProject2

set MyProject3 to make new project with properties {name:"Test project 3"}
duplicate MyAction to end of tasks of MyProject3 with properties {note:"I'm in 3 now!"}

set MyInboxItem to make new inbox task with properties {name:"Stuffs"}
set assigned container of MyInboxItem to MyProject1
end tell
end tell
[/code]

iNik 2007-12-05 08:53 AM

Thanks, Tim! That's a great help. I was missing the "move to end of tasks" portion and was just moving to the project itself (which threw an error).


All times are GMT -8. The time now is 01:06 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.