×

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.

DOWNLOAD SHORTCUT

Setting Shortcut Automation

 1  Device Model • This action returns the model name of the hosting device.

 2  Model Name • The model name of the host device is passed into the Data Input Socket of the “Omni Automation Script” action for OmniFocus.

 3  Tags • The Omni Automation script will reference the tags, creating them if need be. Then is changes the status of each tag accordingly.

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:

Shortcuts Workflow

 1  Enable Automation • Make sure the automation is enable to be run automatically when OmniFocus is opened.

 2  Choose Target App • Set OmniFocus as the targeted application.

 3  Action to Take • Select the “Run Shortcut” action as the action to be performed when the shortcut is launched.

 4  Shortcut • Set the “Set Tags for Device” shortcut as the shortcut to be executed by the “Run Shortcut” action.

That’s it!