Automating Move Up command

Does anyone know how to move a task up in the project list in applescript? The move command requires a location specifier and I am not sure how to specify that I just want the task to move up (i.e., mimicking the keyboard shortcut ctrl-cmd-up arrow).

For context, I am trying to order tasks by tag within a specific project using a keyboard shortcut, so if anyone knows how to do that in either applescript or Keyboard Maestro, it would also work.

Thanks in advance.

FWIW, these are the relevant methods in OmniFocus Javascript API:

Tag : ActiveObject

Instance Functions

function moveTask(task: Task, location: Tag.TaskInsertionLocation)

Moves an existing associated Task within the tag’s list of tasks. If the task is not associated with the tag, no change is made.

function moveTasks(tasks: Array of Task, location: Tag.TaskInsertionLocation)

Moves a list of associated Tasks within the tag’s list of tasks. Any tasks not currently associated with the tag are ignored.

The advantage of using those is that you’d get cross-platform compatibility.

I’ve added a new plug-in:

Omni-Automation/Move Up.omnifocusjs at master · unlocked2412/Omni-Automation

Thanks! However, I don’t know how to use a javascript plugin. Is there an equivalent for applescript?

Just double-click to install.

Move Up.omnifocusjs (2.1 KB)

Thanks. Actually, I’ve expanded what I want to do and it would be useful to be able to do this within an applescript based on a selection. Is there any equivalent for applescript?

I haven’t used OmniFocus Applescript API for a couple of years. All my Omni related apps automations are written in JavaScript, these days.

However, I am sure it’s possible to write an AppleScript that resembles a “move up” command.

There is a move command, but it requires a location specifier and I am not sure how to specify the location. If anyone has some examples of using the move command in an applescript to move tasks within a project, it would be a big help.

FWIW, here you can see an example of the move command in AppleScript, and an example of a location specifier (end of tasks). I posted this in 2017.