The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
AppleScript help: Create sub-task, project from task Thread Tools Search this Thread Display Modes
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!
 
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.
 
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
__________________
CTO, The Omni Group
 
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).
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Applescript, Create Task, Assign resource, Assign dependency dexterama OmniPlan Extras 2 2012-11-18 12:25 PM
Applescript error number -1728 when trying to specify a project name for a new task benlanghals OmniFocus Extras 3 2011-12-30 05:55 PM
Applescript to change the Project of a task? Kha OmniFocus Extras 2 2011-12-19 02:10 PM
Add quick entry task with project using AppleScript iNik OmniFocus Extras 2 2011-08-30 12:40 PM
Create Task with Label kennedyma OmniFocus 1 for Mac 1 2011-06-01 08:05 AM


All times are GMT -8. The time now is 11:18 AM.


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