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 Today's Posts

 
Tally Completion on a Selected Project Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
I am trying to create a simple script to tally the percentage complete on a selected project, where %complete = completed tasks/total tasks. I must admit that I am floundering on issues of windows, documents, contents, and projects (flattened or not). Here is my test starting point ...

Code:
(*
This script calculates a percentage completion on a selected project
*)

tell application "OmniFocus"
	set oC to the content of front window
	set theSelection to (value of every selected tree of oC)
	if ((count of theSelection) < 1) then
		display alert "You must first select a Project to run this." as warning
		return
	end if
	if ((count of theSelection) > 1) then
		display alert "You currently can only select one Project to run this." as warning
		return
	end if
	(*
	if the type of theSelection is not project then
		display alert "You can only run this on a Project." as warning
		return
	end if
	set theNumber to the (number of tasks in theSelection)
        set theNumberCompleted to the (number of completed tasks in theSelection)
        set thePercentage = theNumberCompleted*100/theNumber
	*)
end tell
The first parts work to parse the list for only one project. How do I extract the project from theSelection in order to parse its number of tasks and completed tasks? I also eventually want this script to run on a project that may be selected in either the left or right pane. What caveats apply?

Past the basics, this script could be used in repeat loops to do a statistical report. My immediate end use is to use the percentage completed on a selected project to adjust the value on a corresponding goal in Goalscape.

Thanks!
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up a recurring project with multiple options for completion waynefritsche Applying OmniFocus 9 2011-08-02 10:07 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
New Script - Selected Entourage EMail to Selected OF Task davidsomeone OmniFocus Extras 1 2009-03-06 12:22 PM
Project completion state not being synced to Macs? Richard Flynn OmniFocus Syncing 6 2009-03-03 01:05 AM
Ability to Switch to Project list with Action selected SpiralOcean OmniFocus for iPhone 0 2008-11-20 06:26 AM


All times are GMT -8. The time now is 10:21 AM.


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