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

 
How do I move a project to a specific folder? Thread Tools Search this Thread Display Modes
I am trying to figure out how to move a project from the bottom of the projects list to a specified folder. I am starting by figuring out how to duplicate a selected project to another location. I have:

Code:
tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of sidebar
			set theA to {tree 2 of tree 2 of sidebar of document window id 128 of document id "fqCMFexKSD8" of application "OmniFocus"}
			set theX to (value of item 1 of theSelectedItems)
			set theY to folder of theX
			set theZ to section of theY
			duplicate (value of item 1 of theSelectedItems) to after theA
		end tell
	end tell
end tell
I get:
  • "OmniFocus got an error: Can’t make {tree 2 of tree 2 of sidebar of document window id 128 of document id "fqCMFexKSD8"} into type specifier," when when I try to duplicate the project to after theA.
  • "OmniFocus got an error: Attempted to move data objects to a nil container," when I try to duplicate the project to after theX and theY.
  • "OmniFocus got an error: Can’t make {project id "oxQPHIP8MtA" of document id "fqCMFexKSD8", etc.} into type specifier," when I try to duplicate the project to after theZ.

How do I write a command that will move the selected project to a specified location?

Thanks,
Rebecca
 
On a related note, why is it that:
set theX to (first section whose name is "Vision")
duplicate newTemplate to after theX
does not work, but
duplicate newTemplate to after (first section whose name is "Vision")
does? Grrr.
 
Quote:
Originally Posted by rloconne View Post
On a related note, why is it that:
set theX to (first section whose name is "Vision")
duplicate newTemplate to after theX
does not work

Try:
set theX to a reference to (first section whose name is "Vision")
duplicate newTemplate to after theX
 
I get the error: "OmniFocus got an error: Attempted to move data objects to a nil container." (I am getting really sick of that *#$$ nil container.)

The best solution I have found so far is to move the project from its original position at the bottom of the list to the top level section containing the folder I want the project in, then to the second level section within that section, and so on until I get it to where I want to go:

Code:
-- treePath is a path like "{FolderTop: Folder level 2: etc}"; getPathParts turns it into a list: {"FolderTop", "Folder level 2", "etc"}; newTemplate is a project reference
on moveToSection(treePath, newTemplate)
	tell application "OmniFocus"
		tell front document
			set treePathParts to my getPathParts(treePath)
			
			try
				move newTemplate to after (first section whose name is (item 1 of treePathParts))
				set currentSection to (first section whose name is (item 1 of treePathParts))
			on error
				return false
			end try
			repeat with i from 2 to count of treePathParts
				try
					move newTemplate to after (first section of currentSection whose name is (item i of treePathParts))
					set currentSection to (first section of currentSection whose name is (item i of treePathParts))
				on error errMsg
					return false
					-- The one of the folders named does not exist
				end try
			end repeat
			move newTemplate to after (last section of currentSection)
		end tell
		return currentSection
	end tell
end moveToSection
It works, but it is really slow.

Last edited by rloconne; 2008-01-21 at 07:34 PM..
 
Re: moveToSection

When I say it works, I mean it works as long as the folder you want to move your project to is visible. I'm going to settle for that, but if anyone comes up with a better way to move a project to a folder specified by a string in a note, by all means, please let me know.
 
I have finished version 1 of the scripts I refer to in this thread. You can get them at http://people.engr.ncsu.edu/rloconne...g-projects.htm
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
can't move pre-existing project in to pre-existing folder kbs1138 OmniFocus 1 for Mac 3 2011-06-16 10:22 AM
script to make an inactive project active and move it to a selected folder kingsinger OmniFocus Extras 2 2010-11-15 08:52 PM
How to move project into folder? [A: Tap Edit, tap item, tap "move" button in Tbar.] Avis OmniFocus for iPhone 4 2010-07-07 10:27 AM
Feature Request: Move project from folder to folder jbarr OmniFocus for iPhone 2 2008-07-17 11:10 AM
Please move datafile to Documents folder jasong OmniFocus 1 for Mac 18 2007-11-20 09:51 AM


All times are GMT -8. The time now is 02:59 AM.


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