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

 
Trouble programmatically completing a project Thread Tools Search this Thread Display Modes
Can anyone spot whether I'm doing something stupid here?

The script below is supposed to remove a suffix from an item name and mark the item as completed. (It's a companion script for my Verify Next Actions Exist script.) It seems to work for action groups, but for projects it fails to mark the project as completed.

Code:
property missingNASuffix : "Missing NA"
property missingNADelimiter : "—"
property suffixToStrip : missingNADelimiter & missingNASuffix
property suffixLength : count of suffixToStrip

tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to value of selected trees of content
			repeat with anItem in theSelectedItems
				tell anItem
					if (name ends with suffixToStrip) then
						set completed to true
						set newName to rich text 1 thru (-1 * (suffixLength + 1)) of (get name)
						set name to newName
					end if
				end tell
			end repeat
		end tell
	end tell
end tell
I'll file a bug report if this code looks OK to the other scripters here.
__________________
Cheers,

Curt
 
The completed property of projects used to have another bug, and may have been effectively disabled.

The trick seems to be to set the the status of a project, as in:
Code:
property missingNASuffix : "Missing NA"
property missingNADelimiter : "—"
property suffixToStrip : missingNADelimiter & missingNASuffix
property suffixLength : count of suffixToStrip

tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to value of selected trees of content
			repeat with anItem in theSelectedItems
				tell anItem
					if (name ends with suffixToStrip) then
						-- set completed of anItem to true
						set status of anItem to done
						set newName to rich text 1 thru (-1 * (suffixLength + 1)) of (get name)
						set name to newName
					end if
				end tell
			end repeat
		end tell
	end tell
end tell

Last edited by RobTrew; 2009-07-30 at 09:55 AM..
 
Thanks, Rob. That, with a snippet to check the item's class, did the trick.
__________________
Cheers,

Curt
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble getting iPad project to build andyboyd Omni Frameworks 1 2012-09-25 02:14 AM
Completing actions... StevenMay OmniFocus for iPad 3 2011-10-07 09:25 PM
Trouble Importing mpp from MS Project Manager nerea OmniPlan Extras 5 2009-11-01 07:14 AM
Rendering OG programmatically 0x6e6562 OmniGraffle General 1 2009-10-27 02:16 PM
Keyboard shortcut for completing a project SpiralOcean OmniFocus 1 for Mac 0 2007-09-30 06:40 PM


All times are GMT -8. The time now is 09:31 AM.


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