Make new task problems
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[/CODE] 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."[/CODE] 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."[/CODE] 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[/CODE] |
All times are GMT -8. The time now is 01:30 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.