OmniFocus: Set Tags for Device
This is a shortcut that sets the status of specific tags depending upon the device hosting OmniFocus. For example, if OmniFocus is opened on an iPad, the status of the tag “iPad” will be set to active, while the status of tags “iPhone” and “Mac” will be set to on-hold.
On iPads and iPhones this shortcut can be set to automatically execute when OmniFocus is launched.
The Shortcut
The following details the components of the shortcut.
The Omni Automation Script
This script references the three device tags, creating them if they don’t exist. It them changes the status for each tag based upon the type of the host device.
Set Status of Tags for Host Device
allTags = flattenedTags
iPadTag = allTags.byName("iPad") || new Tag("iPad")
iPhoneTag = allTags.byName("iPhone") || new Tag("iPhone")
macTag = allTags.byName("Mac") || new Tag("Mac")
if (argument.input.startsWith("iPad")){
iPadTag.status = Tag.Status.Active
iPhoneTag.status = Tag.Status.OnHold
macTag.status = Tag.Status.OnHold
} else if (argument.input.startsWith("iPhone")){
iPadTag.status = Tag.Status.OnHold
iPhoneTag.status = Tag.Status.Active
macTag.status = Tag.Status.OnHold
} else if (argument.input.startsWith("Mac")){
iPadTag.status = Tag.Status.OnHold
iPhoneTag.status = Tag.Status.OnHold
macTag.status = Tag.Status.Active
}
Assigning Shortcut as Automation
On iPhones and iPads this shortcut can be set to execute whenever OmniFocus is launched. Here’s how to create a Shortcuts automation using the shortcut (workflow).
In the Shortcuts application, create a new Personal Automation using the “App” automation trigger, and then follow these steps:
That’s it!