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

 
Script: Conditional review frequency Thread Tools Search this Thread Display Modes
An illustrative draft, in response to a request in the OmniFocus for Mac forum, for a way of setting review interval according to project status.

Requires a filter clause for each type of project. You can experiment with the clauses, to get them right, using the assisted query-editing menus in my Where in OF script.

Code:
-- Ver 0.3 Rob Trew
-- Only for OmniFocus 1.8 and above
-- 	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-- 	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
-- 	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-- 	IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
-- 	ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- 	 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-- 	 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-- 	 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-- 	 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

tell application id "com.omnigroup.omnifocus"
	
	-- EDIT THE  LINE BELOW TO MODIFY OR ADD CONDITIONS.
	
	-- THE CLAUSE OF EACH TRIPLET MUST BE A WELL-FORMED FILTER CLAUSE
	-- (YOU CAN EXPERIMENT WITH THE CLAUSES, TO GET THEM RIGHT, USING 
	-- THE "WHERE IN OF" SCRIPT AT http:/bit.ly/OF-Find2 )
	
	-- EDIT HERE:
	-----------------------------------------------------------------------------
	set lstCycles to {{"status is on hold", week, 6}, {"status is active", day, 4}}
	-----------------------------------------------------------------------------
	
	set oDoc to default document
	tell oDoc
		repeat with oProjType in lstCycles
			set {strClause, eUnit, lngSteps} to oProjType
			set oScript to run script my QueryScript(strClause)
			
			set lstProjects to GetProjects(oDoc) of oScript
			repeat with oProj in lstProjects
				set review interval of oProj to {unit:eUnit, steps:lngSteps}
			end repeat
		end repeat
	end tell
end tell

on QueryScript(strQuery)
	"
script
	on GetProjects(oDoc)
		tell application id " & quote & "com.omnigroup.OmniFocus" & quote & "
				tell oDoc to return flattened projects where " & strQuery & "
		end tell
	end GetProjects
end script
"
end QueryScript

Last edited by RobTrew; 2012-07-17 at 06:57 AM.. Reason: Typo
 
Thanks Rob!
 
Hmm, so I'm a little ignorant of AppleScript. Would I install this in ~/Library/Scripts/Applications/OmniFocus and then run it from the toolbar when I want to adjust the review intervals?
 
I believe I just answered my own question. It works pretty well in that manner.

Can you think of any way to cause this to be triggered by the act of setting a project to Hold/Active? Or maybe just running it at a regular interval would do the trick?
 
Quote:
Originally Posted by ende View Post
Can you think of any way to cause this to be triggered by the act of setting a project to Hold/Active?
OmniFocus applescript doesn't currently allow us to have scripts triggered by events, but I think it should be enough to do it just before you look at a list of things to be reviewed.

Assuming that you are using a "Review" perspective, one approach would be to use a modified version of this script as your usual way of opening that perspective.

If we make the script do this after it updates review intervals according to project status:
Code:
-- NOW OPEN A NEW WINDOW WITH A "REVIEW" PERSPECTIVE
		set oWin to make new document window
		set perspective name of oWin to "Review"
Then always opening the Review perspective with this script might be a useful way of ensuring that you always see an updated view of what needs reviewing.

(Each project has a "last reviewed" date stamp, and calculates the Next Review date as a simple function of last reviewed date + the review interval. A "just in time" approach to conditionally resetting the review intervals [i.e. reset when, and only when, you look at the Review perspective] should work well, as the "last reviewed" date is not affected by resetting the interval).

Here is a modified version of the script, which could be used in this way, if you install it on your toolbar.

Code:
-- Ver 0.4 Rob Trew

-- Opens a new Review Perpective window, after updating project review intervals according to project status

-- Only for OmniFocus 1.8 and above
-- 	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-- 	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
-- 	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-- 	IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
-- 	ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- 	 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-- 	 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-- 	 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-- 	 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

tell application id "com.omnigroup.omnifocus"
	
	-- EDIT THE  LINE BELOW TO MODIFY OR ADD CONDITIONS.
	
	-- THE CLAUSE OF EACH TRIPLET MUST BE A WELL-FORMED FILTER CLAUSE
	-- (YOU CAN EXPERIMENT WITH THE CLAUSES, TO GET THEM RIGHT, USING 
	-- THE "WHERE IN OF" SCRIPT AT http:/bit.ly/OF-Find2 )
	
	-- EDIT HERE:
	-----------------------------------------------------------------------------
	set lstCycles to {{"status is on hold", week, 1}, {"status is active", day, 1}}
	-----------------------------------------------------------------------------
	
	set oDoc to default document
	tell oDoc
		repeat with oProjType in lstCycles
			set {strClause, eUnit, lngSteps} to oProjType
			set oScript to run script my QueryScript(strClause)
			
			set lstProjects to GetProjects(oDoc) of oScript
			repeat with oProj in lstProjects
				set review interval of oProj to {unit:eUnit, steps:lngSteps}
			end repeat
		end repeat
		
		-- NOW OPEN A NEW WINDOW WITH A "REVIEW" PERSPECTIVE
		set oWin to make new document window
		set perspective name of oWin to "Review"
	end tell
end tell

on QueryScript(strQuery)
	"
script
	on GetProjects(oDoc)
		tell application id " & quote & "com.omnigroup.OmniFocus" & quote & "
				tell oDoc to return flattened projects where " & strQuery & "
		end tell
	end GetProjects
end script
"
end QueryScript

Last edited by RobTrew; 2012-07-17 at 08:18 AM..
 
 




Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to make mutiple copies of a task in a "review" action list with different start dates jimi23 OmniFocus 1 for Mac 3 2013-02-17 10:56 PM
Setting review frequency ende OmniFocus 1 for Mac 1 2010-09-13 08:32 AM
Syncing Frequency? torchy OmniFocus Syncing 1 2010-07-31 05:35 AM
Conditional/Branching project lrivers OmniPlan General 0 2010-06-10 10:02 AM
RSS Frequency theonehorst OmniWeb Feature Requests 1 2007-11-20 11:38 AM


All times are GMT -8. The time now is 02:18 PM.


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