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

Deleting estimated time from script? Thread Tools Search this Thread Display Modes
I'm having trouble figuring out how to delete the estimated time from a script.

Say I wanted to write a script that would toggle the estimated time of the current task from nothing to something and back. One might think I could write:

property newTimeEstimate : 3 -- minutes

tell application "OmniFocus"
	set theDoc to document window 1 of document 1
	set selectedTask to the value of the first item of the selected tree of the content of theDoc
	tell me to toggleTask(selectedTask)
end tell

on toggleTask(mainTask)
	using terms from application "OmniFocus"
		set estimatedMins to estimated minutes of mainTask
		if estimatedMins is missing value then
			set estimated minutes of mainTask to newTimeEstimate
			set estimated minutes of mainTask to missing value
		end if
	end using terms from
end toggleTask
If you run this script on a task with no estimated time, it sets the time to 3m, as expected. Unfortunately, if you run it again, rather than removing the estimated time, it sets it to 0m. "missing value" doesn't match "0m", so the script doesn't actually toggle; it goes nothing → 3m → 0m.

Of course, in this contrived script, I could just change if estimatedMins is missing value to if estimatedMins is 0 or estimatedMins is missing value, and that would make it work, but for my larger problem, its possible that some items might actually have an existing estimated time of 0, and I need to differentiate them from ones that have no estimated value set at all. (Also, the "Unestimated" filter does not match 0m, only the unset value.)

I've tried delete (estimated minutes of mainTask) and set estimated minutes of mainTask to "", and these do not work.

Apologies if the answer is obvious—my AppleScript isn't great. (It looks like the Python, Ruby and Perl interfaces to OmniFocus I see floating around on the web all bridge through AppleScript, so I haven't tried any of these, but if I'm wrong and one of them is a first-class API, by all means let me know, since I'd rather not struggle with a language I'm unfamiliar with!)
It wouldn't be the first bug in their applescript implementation...from my reading of the dictionary, setting the value to missing value ought to put it back to not having any estimated duration, but I agree that that often isn't the result obtained. Use Help->Send Feedback to file a bug report.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Estimated Time — Daily Limits hobartimus OmniFocus 1 for Mac 7 2012-04-16 12:50 PM
Estimated Time of Zero skillet OmniFocus 1 for Mac 2 2012-04-09 01:22 PM
Estimated Time? sirluce OmniFocus for iPad 3 2010-12-03 03:55 AM
Searching for exact estimated time BevvyB OmniFocus 1 for Mac 1 2009-04-02 03:18 PM
Please help finish a script to launch Minuteur with a task's estimated time smew OmniFocus Extras 19 2008-10-29 01:24 PM

All times are GMT -8. The time now is 06:49 PM.

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