Get tag from task with shortcuts

It is a curious omission that you can’t get the tag out of the Shortcuts magic variable for the task. You can get the tags with Omni Automation JavaScript as stated above. You can call Omni Automations from Shortcuts as previously discussed at Call x-callback-url from OmniJS?. The image below is an example.

The Find … Items action has been limited to only 1 item. For multiple items, you would need to be more creative.

There are several limitations with this approach:

  • From OmniFocus’ perspective, it is being asked to run potentially unsafe code. Consequently, it will ask for your confirmation each time. See https://omni-automation.com/script-security.html for details. It is possible to disable the warning but I recommend against this as it would be unsafe.
  • Currently, I get an “OmniFocus does not handle “shortcuts-production” URLs” error but the script works fine once you dismiss the error. I don’t use the callbacks myself so I don’t know if the issue is new. It smells like a bug so I would recommend contacting support if you end up using it.
  • Bouncing back and forth between Shortcuts and OmniFocus with URLs is cumbersome and slow.

You may wish to consider using a different technology, My understanding is that the JXA you mentioned is a Mac-only system technology that uses the JavaScript Core language to access the same resources available as AppleScript. On iOS, Apple only provides Shortcuts, not JXA. Omni Automation is a cross-platform feature of the Omni apps that uses the same JavaScript Core language but exposes only resources that are specific to Omni’s apps.

You could move more or all of your logic into an Omni Automation action that lives within OmniFocus. OmniFocus actions can be triggered from Shortcuts using modifications to the URL method described above. If you instead start the automation from OmniFocus, it can hand off to Shortcuts as described at https://omni-automation.com/shortcuts/index.html.

1 Like