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

 
Make new task problems Thread Tools Search this Thread Display Modes
I'm having some problems with a script I'm writing. The idea is to have a script that will create a series of tasks automatically by incrementing a number. For example, say you have a homework set to do for school, and it's problems 1 through 10, if you want one action for each problem, rather than spending a lot of time creating 10 actions (the problem gets worse as the number of problems increases), I want to have a script that automates the process. Here is what I have so far:

Code:
tell application "OmniFocus"
	tell front document
		tell (first document window whose index is 1)
			try
				set actionTitle to display dialog "Title for action, sequence number will appear at end" default answer "Problem #"
			on error
				return
			end try
			
			try
				set startingIndexResponse to display dialog "Enter starting index number" default answer "1"
				set startingIndex to startingIndexResponse's text returned as integer
			on error
				return
			end try
			
			try
				set endingIndexResponse to display dialog "Enter ending index number" default answer "10"
				set endingIndex to endingIndexResponse's text returned as integer
			on error
				return
			end try
			
			set actionLocation to tasks of containing project of value of selected trees of content
			set i to 0
			repeat with i from startingIndex to endingIndex
				set newAction to make new task with properties {name:(actionTitle & (i as rich text))}
				move newAction to end of actionLocation
			end repeat
			
		end tell
	end tell
end tell
I get various errors with the loop depending on how I vary the code. As it appears this will generate an error of

Code:
make new task with properties {name:{text returned:"Problem #", button returned:"OK", «class ktxt»:"1"}}
		"OmniFocus got an error: Can’t make or move that element into that container."
but if I change the code to specify a location when creating the new task I get an error about the specifier for the location:

Code:
make new task at end of {{task id "pOhErpXJ0v0" of document id "cIQtWwBZUKy", task id "orFUBtat5ex" of document id "cIQtWwBZUKy", task id "nYSFQypfzJG" of document id "cIQtWwBZUKy", task id "dna1GTquTdK" of document id "cIQtWwBZUKy", task id "aEUL_tWw8bq" of document id "cIQtWwBZUKy", task id "hIG8Rsv8Dbe" of document id "cIQtWwBZUKy", task id "bDFT5oCOnX9" of document id "cIQtWwBZUKy", task id "nUat8J3olgG" of document id "cIQtWwBZUKy", task id "cCm91x5tbhl" of document id "cIQtWwBZUKy", task id "hpap4LrBsGO" of document id "cIQtWwBZUKy", task id "izNkHuwo8jQ" of document id "cIQtWwBZUKy", task id "bGGNL_c6orr" of document id "cIQtWwBZUKy", task id "i2-Kf91D-kh" of document id "cIQtWwBZUKy", task id "docgQELzizB" of document id "cIQtWwBZUKy", task id "akjn2qZwC3R" of document id "cIQtWwBZUKy", task id "jwMA1ZkANaH" of document id "cIQtWwBZUKy"}} with properties {name:{text returned:"Problem #", button returned:"OK", «class ktxt»:"1"}}
		"OmniFocus got an error: Can’t make {{task id \"pOhErpXJ0v0\" of document id \"cIQtWwBZUKy\", task id \"orFUBtat5ex\" of document id \"cIQtWwBZUKy\", task id \"nYSFQypfzJG\" of document id \"cIQtWwBZUKy\", task id \"dna1GTquTdK\" of document id \"cIQtWwBZUKy\", task id \"aEUL_tWw8bq\" of document id \"cIQtWwBZUKy\", task id \"hIG8Rsv8Dbe\" of document id \"cIQtWwBZUKy\", task id \"bDFT5oCOnX9\" of document id \"cIQtWwBZUKy\", task id \"nUat8J3olgG\" of document id \"cIQtWwBZUKy\", task id \"cCm91x5tbhl\" of document id \"cIQtWwBZUKy\", task id \"hpap4LrBsGO\" of document id \"cIQtWwBZUKy\", task id \"izNkHuwo8jQ\" of document id \"cIQtWwBZUKy\", task id \"bGGNL_c6orr\" of document id \"cIQtWwBZUKy\", task id \"i2-Kf91D-kh\" of document id \"cIQtWwBZUKy\", task id \"docgQELzizB\" of document id \"cIQtWwBZUKy\", task id \"akjn2qZwC3R\" of document id \"cIQtWwBZUKy\", task id \"jwMA1ZkANaH\" of document id \"cIQtWwBZUKy\"}} into type specifier."
and this seems to happen no matter how I try to give the specifier for the location. Any tips on what I'm doing wrong? It seems to me like this should be a relatively simple script to write, but getting the location for the new task right appears to be quite a problem.
 
You are trying to tell the window to make new tasks.

Windows can't make tasks - you need to tell a specific project, (or another task if you are making subtasks), or perhaps the inbox, to do this.

It might be helpful to try running the following:

Code:
tell application "OmniFocus"
	tell front document
		set oFolder to make new folder with properties {name:"Displacement Activities"}
		tell oFolder
			set oProject to make new project with properties {name:"Learn to script OF"}
		end tell
		tell oProject
			set oTask to make new task with properties {name:"Study the OF dictionary"}
		end tell
		tell oTask
			set oSubTask to make new task with properties {name:"Check which objects have tasks as children"}
		end tell
	end tell
end tell

Last edited by RobTrew; 2009-06-28 at 11:40 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I forward a E-Mail to Omni and you make it a task? Librerio Applying OmniFocus 1 2011-10-30 02:37 AM
How to make a task nonrepeating? scb OmniFocus Extras 7 2011-09-16 05:37 PM
Please make a way to tell the difference between projects and task Forecast view! pik80 OmniFocus for iPhone 14 2011-09-08 09:35 PM
Way to make a daily task only on weekdays? cshumate OmniFocus 1 for Mac 2 2009-01-11 04:06 PM
make new inbox task Jacco OmniFocus Extras 2 2008-02-18 09:12 AM


All times are GMT -8. The time now is 09:22 PM.


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