Help with Omnifocus "Focus" feature

Hi there MPU community -

I’m trying to figure out how to do something simple in Omnifocus, but I can’t seem to find a way to do it. I would like to create a button (either a perspective, an omnifocus script, or whatever) that automatically opens up a folder (of projects) and focuses. I can do this manually by opening the folder and clicking View > Focus on “ProjectName” but I want to add a icon to my Tool Bar that does this.

This was possible in OmniFocus 2 with the old perspectives, but I see they’ve removed the ability to focus on projects in OmniFocus 3 (along with focusing on contexts, apparently). Anyone know why they did this? I hope they bring it back in Omnifocus 4. That was one of the killer features of Omnifocus.

It should be possible. In the perspective options, look for “contained within project or folder” and “Tagged with any of:”. For group and sort, choose Entire Projects. Star the perspective to add it to the sidebar. Then you can click the perspective icon and your view should be restricted to the projects within the folder you selected for “contained within…”

It’s not literally the focus feature, but the effect is the same.

1 Like

Yeah, second what @cornchip said. You can’t just add a button to the toolbar to dive into the perspective anymore, but it’ll work similarly.

Ah, this is helpful! It’s not quite what I’m looking for though - with the Focus mode I can sort by context within a project, which is what I’m looking for.

With focus, if I have a Perspective that is “Work” and then I want to see “What are the emails in work?” I can click the ‘email’ tag and it only shows me the emails that are within that project. This is the killer feature for me, it allows me to ‘focus’ on a subset of my work without losing the sorting and filtering capabilities of the full Omnifocus software.

Ah, didn’t think about that aspect. I wish I had a solution for you. Do you own something like Keyboard Maestro? You could use it to make OmniFocus active, cmd+o, type the project name, enter, cmd+shift+f.

I have some AppleScript scripts that may accomplish what you need. One of them (not created by me) takes a selected action and then opens a new window focused on that project. Then the second variety activates focus mode on a particular folder or set of folders. They are, not surprisingly, easy to modify. Do either of these sound like what you might be looking for?

That would be perfect! The 2nd one is what I’m looking for in this particular case. Do you mind sharing?

Here is the exact text of my script. Paste it into Script Editor and save it in the OF 3 script folder. When you compile it, Script Editor will format it correctly. Change the folder names in the script to ones that you have just to test it out.

-- This script focuses on my trial practice work by focusing on my three work-related roles: Trial Lawyer, Rainmaker, and partner

(* tell application "OmniFocus"
	tell the default document
		set folderslist to flattened("Trial Lawyer", "Rainmaker", "Partner")
		-- set folderList to folders whose name is (choose from list folderslist with title "Projects Focus" with prompt "Select Folder to focus on" default items " ")
		tell the front document window
			set thePerspective to "Projects"
			set perspective name to thePerspective
			set focus to folderslist
		end tell
	end tell
end tell *)

tell application "OmniFocus"
	tell the default document
		set listChoices to {"Trial Lawyer", "Rainmaker", "Partner"}
		set folderList to flattened folders whose name is (item 1 of listChoices)
		tell the front document window
			set focus to folderList
		end tell
		set folderList to flattened folders whose name is (item 2 of listChoices)
		tell the front document window
			add folderList to focus
		end tell
		set folderList to flattened folders whose name is (item 3 of listChoices)
		tell the front document window
			add folderList to focus
		end tell
	end tell
end tell

I have custom icons for these scripts and I add them to the toolbar for easy access. I’ll probably convert these from AppleScript to Omni’s own JS automation and when I do I’ll update this message.

*** one additional note. The parenthetical that starts with (* and ends with *) is a commented out section of code that you can remove. I think I was experimenting with something that didn’t work there. Anyway, it has no effect on the script at all. So you can excise that portion.

1 Like

I was able to convert the script to take advantage of Omni’s new javascript automation. Here is the new version. Works the same as above – but if you are using the OmniFocus 4 beta, it will work on your IOS devices, which is pretty cool.

	"author": "Thomas H. Vidal",
	"targets": ["omnifocus"],
	"type": "action",
	"identifier": "com.darkmattersoftware.omnifocus.workfocus",
	"version": "1.0",
	"description": "Focus on all trial practice work.",
	"label": "Focus: Trial Lawyer",
	"mediumLabel": "Trial Lawyer",
	"paletteLabel": "Trial Lawyer",
(() => {
	var action = new PlugIn.Action(function(selection, sender){
      // Action code
      focusFolders = [folderNamed("Trial Lawyer"), folderNamed("Partner"), folderNamed("Rainmaker")][0].focus = focusFolders

	return action;

save this with a name that ends with an extension of “omnijs” and save it in your OmniFocus plugin directory.

1 Like