Omnifocus 3 macOS order tags script

I have been looking into OmniFocus 3 on mac and noticed that there isn’t any updated documentation / updated applescripts for the new version. Sure, most of the things stayed the same, but it would be great if there was more documentation related to those changes. The applescript dictionary is up to date I think, but some nuances weren’t very clear to me.
Of course, the biggest change is that we now have tags, hence each action can have ordered set of tag items. I have recently dedicated myself to using OmniFocus and one thing I felt was missing (I used Things 3 previously) was that the tags shown in the actions don’t have any set order - they are simply ordered there based on when were they added. Since I like structure, I wanted to order them according to some hierarchy. This was simple enough to do in applescript after playing for a while with the new applescript dictionary. So, I wanted to link the repository here for reference and if anyone has the same inkling for structure: imo, if the tags aren’t ordered, you have a lot of them and you have a lot of tasks in some perspective then it can be a mess to look at.
More description is on github: OmniFocusScripts

I have updated the repository and added a new script. I will be adding more scripts shortly. Some scripts might be similar to what Brandon Pittman has done, but hopefully people might still find this useful.

I also added a folder with some .icns icons so that people can give their applescripts in the toolbar some visual flair. I have used fontawesome collection and converted them to .icns format. Plus, you can find the icons in different colors - I used colors from OmniFocus dark mode palette. I will be adding some new icons when I have time.

Scripts and Icons

This is a necessary thing to have, thank you for putting it together.
Any chance you would want to modify this one or create a new one that works with OmniFocus 2 for Mac?

Reason I ask is to help OF2 for Mac work well with OF3 for iOS by prioritizing certain Tags/Contexts as you do here in order to have OF2 pick up on the most important Tag for a given task. OF2 only shows the first Tag listed, and there’s no option to have it show the first Tag a task has in ‘Tag order.’

That way, on OF3 for iOS, I could list tags in an order that makes sense while relying on OF2 selecting the sole Context based on priority thanks to a script.

I am relegated to Sierra thanks to FCP7. I know, I know, but I’m not a professional and I have years’ worth of misc work invested in it because my prior machine couldn’t run the then-current FCPX. It seems that I’m perpetually behind the curve on Mac hardware. If it wasn’t for great software like OmniFocus I might just leave the platform for my own good (with tears).

I am not 100 percent sure if I understand you. Do you mean you would want to put your tasks with multiple tags in iOS OmniFocus and then using the script to pick out the most important tag?

No, not exactly. OF2 is capable of parsing an OF3 database containing tasks with multiple tags, but it can only show one as it’s context. Whichever tag happens to be listed first is what OF2 will consider to be that task’s context.

For example, if I have a task called “Purchase several hamsters” tagged with “Store,” “Manic,” and, “Purple Monkey Dishwasher” in OF3 for iOS, when it is synced to OF2 for Mac it will show a context of “Store.” If you look under the other two contexts in OF2, it will not appear there.

More or less, I’ve chosen to keep most of the tags I formerly used as contexts in the days before OF3 under a tag labeled “Contexts,” with other tags representing other dimensions worth tagging, like energy level or people associated with the tasks. Then I have a few OF2-compatible custom perspectives set up the way they always have been in order to show me my ‘next actions’ which use this “Contexts” tag header.

If a task created with OF3 has a “Context” tag, I would like OF2 to reckon that tag as its context regardless of what other tags it might have. If I labeled the above example task with “Manic” first, it would not appear in my OF2 perspective which picks up on “Contexts,” which “Store” would belong to.

What would have been neat is for OF2 to pick the tag which comes first by ‘tag order’ (the order tags are listed in the Tags perspective) as a task’s OF2 Context rather than which is listed first in the task itself.

A script that, say, once a day combs through all tasks (or perhaps just tasks becoming available within a certain date range for speed and efficiency) in the synced database and sorts tasks’ assigned tags by the ‘tag order.’ I know OF2 for Mac has the information in the database for all of a task’s multiple tags even though it only displays one, but I do not even know if an OF2 script would be able to pick up on this in order to perform this function.

I was looking at this and I don’t think it’s possible. The AppleScript library for OmniFocus 2 seems to not be able to access the multiple tags assigned to a task even though this information might be in the database. Since I don’t think it’s possible to interact with the database directly (I know that in Things for instance, you could query the sqlite database, but OmniFocus seems to have more complex setup since it syncs with their private servers), I am not sure how could I implement this. If anyone has an idea, please let me know.

I didn’t think it would work, but I appreciate you taking the time to ensure that we’re not missing out on something that would be useful.