Script to defer all 'Work' folder's projects to Monday?

I know nothing about programming, but have enjoyed finding ways the iOS app Workflow can help automate things for OmniFocus, as that is the primary platform I use for it, timewise.
One thing that Workflow has no way of doing is getting content from OmniFocus apart from sharing it, one selectable chunk at a time. So, if what I am asking about below if possible, it’d have to be done on the Mac with AppleScript.
What I’d like to do is run a script on the Mac, preferably triggered by a Mail action, at the end of the day on Friday to automatically defer all projects in my ‘Work’ folder to the coming Monday. (Except, of course, any projects already deferred past then.) Or, even better would be to defer all individual tasks that currently appear within a particular custom perspective. Sometimes work tasks include things to buy at the store, so if I happen to be someplace where I can complete the action on a Saturday I’d want to. But deferring the tasks in my custom perspective for general, do-anywhere work until Monday would remove those things from sight but allow other things that I’ve intentionally kept out of it to be available in other perspectives where they may serve a purpose.
This would allow me to dispense with some of my custom perspectives that only show me stuff to worry about on weekends and help me keep things simple.

1 Like

Sorry but I can’t answer your question directly about applescripting. Why not just leave all projects on hold and just choose 3 projects as your Big Rocks for the week? When you have chosen the 3 Big Rocks, change the project status to active. At the end of the week, go to the projects perspective and either keep the current Big Rocks or set some projects between Active and On Hold.

There would be no need to defer on a weekly basis. All projects that aren’t being worked on this week are on hold. Setting a fake defer/start date is frustrating because a project is really On Hold (Someday/maybe). Set a defer date on projects only if you know you will be starting on a particular date.

2 Likes

What you want can be created in Applescript. Essentially, you get all tasks in current perspective and shift their defer dates to the next coming Monday.

An alternative is to put action items in to one project or into a “Workdays Only” sub-group. Then just defer that project or sub-group. The advantage is, this works on both the macOS and the iOS platforms.


JJW

1 Like

In case you would be further interested, here are some links with options to change defer dates.


JJW

Thanks for the responses. Using Workflow on iOS feels like playing with blocks and I have zero knowledge of scripting, so I think I’ll have to leave this as a manual task to perform when I happen to be at my Mac once the weekend has begun. It’d be nice to trigger this from my phone as a Mail action to clear out my single ‘Next Actions’ list quickly on a Friday, or perhaps even daily basis, to let me only see personal tasks until I shift back into professional mode again.
Or, perhaps Workflow will gain further access into OmniFocus in the future.

A feature request that has been discussed in the forums has been batch editing for OmniFocus for iOS. Crossing my fingers and hoping that this will be added in a future update to OmniFocus for iOS. That way, you’ll be able to batch select a bunch of projects and set the defer date in one fell swoop.

2 Likes

+1, @SupportHumans \0/

That would definitely be the ideal solution for this need. The topic linked to says “Coming in 2017” so it seems like it’s only a matter of time. Thanks!

I handle this in two ways. First, as I suggested, I have a Project called “Weekend Warrior”. I put all of my single action tasks that a weekend chores in this Project. I defer the entire Project until Friday at 6pm. On Sunday, I shift the defer date of the Project forward again.

The second approach is to use selective Contexts. I have a top level called Personal. Under it are such Contexts as Errands, Home, Family … Depending on my location and/or schedule, I put those Contexts to an “on hold” status. Indeed, I have an Applescript that allows me to switch my primary context location among Focus, Work, Home, and All. The Applescript selectively activates or puts on hold those Contexts associated with the desired location. The downside is, the script is on macOS. When I am at my iPad and need to change the context location, I have to toggle the status on at a time.


JJW

1 Like

Placing my ‘Work’ Contexts on hold would be an elegant solution too. Would you mind sharing the script you use for this? It sounds like all I’d have to do is swap out the names of my particular Contexts.

Here it is …

(*
This script toggles contexts between work and play
	version 2.4 (jjw) - public release
*)

property pVersion : "2.4"
-- contexts for work
property pWorkContexts : {"Office", "Desk", "Lab"}
-- contexts for personal
property pPersonalContexts : {"Homes", "errands", "Personal", "bills"}
-- other general contexts when focus is off
property pFocusOffContexts : {"start", "someday", "WoO"}
-- show notifications?
property pShowNotice : true -- show notification
-- dialog title bar
property pTitle : pVersion & ": Where are you?"

-- do NOT change this
property gCurrentLocation : "All"

on run

-- set everything to default

set patWork to false
set patPersonal to false
set patFocus to false

-- set location

set theLocation to ¬
	(choose from list {"Focus", "Work", "Personal", "All"} with title pTitle default items gCurrentLocation)

if theLocation is false then return

if theLocation is equal to {"Focus"} then set patFocus to true
if theLocation is equal to {"Work"} then set patWork to true
if theLocation is equal to {"Personal"} then set patPersonal to true
if theLocation is equal to {"All"} then
	set patWork to true
	set patPersonal to true
end if

set gCurrentLocation to theLocation

-- toggle OF contexts and synchronize

tell application "OmniFocus"
	tell front document
		repeat with pContext in pWorkContexts
			set idtoToggleList to every item of (complete pContext as context)
			repeat with pLC in idtoToggleList
				set idtoToggle to id of pLC
				tell context id idtoToggle to set its allows next action to patWork
			end repeat
		end repeat
		repeat with pContext in pPersonalContexts
			set idtoToggleList to every item of (complete pContext as context)
			repeat with pLC in idtoToggleList
				set idtoToggle to id of pLC
				tell context id idtoToggle to set its allows next action to patPersonal
			end repeat
		end repeat
		repeat with pContext in pFocusOffContexts
			set idtoToggleList to every item of (complete pContext as context)
			repeat with pLC in idtoToggleList
				set idtoToggle to id of pLC
				tell context id idtoToggle to set its allows next action to not patFocus
			end repeat
		end repeat
	end tell
	synchronize
end tell

-- send notice to center

if (pShowNotice) then
	set theNotice to "You are now at " & the text of theLocation
	display notification theNotice with title "Applescript: Toggle OF Location" subtitle ((current date) as text)
	delay 1
end if
end run

Copy and paste to the Applescript editor. Compile and save. I run this as an application from the Applescript menu bar.


JJW

1 Like

Wow, thank you! I will play with it when I can and see if I can strip it of everything other than flipping defined Contexts into ‘active’ or ‘on hold.’

Fantastic! I have two scrips now, one to put all Work contexts on hold, and another to re-activate them. I connected these to Automator folder actions pointed at specific Dropbox folders. Now I have shortcuts on my iPhone homescreen to Workflow actions to trigger them to run on my Mac. I can now essentially “punch in” or “punch out” from my phone. (Also have Calendar events to run the ‘punch in’ script each weekday at 4AM.)
Thanks!

Added to the item we have open on this - thanks!

1 Like