How to set column type "duration" via AppleScript?

Hello everyone!

I am trying to accomplish the following. I would like to change settings (red underline squigle on screenshot below) of column type “duration” via AppleScript.

Typically, I would use “column format” property like in the screenshot below:

However, when the column is of type “duration”, the property is empty. I have asked OO support (via email) and they have directed me here. Here’s the screenshot explaining what I mean:

Apparently, you can’t do that. I opened Script Debbuger and, as you say, the column format property is a record of 0 items.

Do you think it’s a bug? Or a missing feature? Any workaround for this? I imagine it’s not a very popular feature (column type “duration”) since it wasn’t addressed previously (tried Google search without much lack)?

I don’t know if this feature was planned. We need to ask Omni for that.
What’s your desired workflow? What do you need to accomplish? Maybe you can resort to GUI Scripting as a last step.

In a nutshell, I am using OF with projects which have deadlines. Since I adhere to GTD workflow, part of the process of choosing the next action is a priority. I determine priority based on the number of the days before the deadline of the project. Currently, I use column type “number” which represents the number of days before the deadline. I figured that “duration” type would be more appropriate for this task. (I find that knowing how many days left before the actual deadline is more effective rather than looking at the due date itself)

I see. What part of your workflow are you trying to automate?

FWIW these settings do seem to be accessible through omniJS in the current test builds of OO 5.2

Adjusting this line at the top of the code below to match the name of your duration column:

const columnTitle = "Duration"; // Adjust as required

and then choosing OmniOutliner > Automation > Show Console, and pasting and entering the code (make sure that you have selected and copied it all)

(() => {

    // NAME OF COLUMN TO ADJUST BY SCRIPT ------------------------------------

    const columnTitle = "Duration";  // Adjust as required

    // GENERIC FUNCTION ------------------------------------------------------

    // show :: Int -> a -> Indented String
    // show :: a -> String
    const show = (...x) =>
            null, x.length > 1 ? [x[1], null, x[0]] : x

    const colFormat = columns.byTitle(columnTitle)

    // CHANGE A SETTING OR TWO -----------------------------------------------
    colFormat.hoursPerWeek = 36;
    colFormat.hoursPerDay = 6;
    colFormat.useVerboseFormat = false;

    // CHECK SETTINGS --------------------------------------------------------
    return show(2, {
        'hours per week': colFormat.hoursPerWeek,
        'hours per day': colFormat.hoursPerDay,
        'long format': colFormat.useVerboseFormat

We get a result which shows that the model has indeed been updated (and the editor display turns out to have changed too);

Setting the column type to “duration” automatically does conversion e.g. 7 days into the week, 30 days into the month, etc. Unfortunately, the default “duration” setting is for work days so values get converted incorrectly if I change the column type after it was populated with data. My desired setting is calendar week. In a nutshell, if I could automatically convert days into more appropriate (i.e. more user-friendly) time format, that’s what I am looking to achieve with AppleScript.

In regards to OmniJS, does it mean that potentially it is possible to modify settings of column type “duration” in an undocumented way? I know for example, that, officially there is no way to create a clickable hyperlink but there is an unofficial way - link.

Probably a question for Omni Support thru Help > Contact Omni, I think

I see the problem. But, if you populate the outline with data and change the duration format via Applescript (but it’s not possible), you would get the same behaviour, I think.

I tried asking support but they said it was outside the scope of support.

As the script is creating a new document (not amending an existing one), if I set the column type/settings correctly before populating data, it works fine (verified behaviour via manual input).

I am searching how to set the duration of a newly created action via AppleScript. Hopefully this is possible now.

At least with OmniAutomation, it’s not possible to set the column type (it’s a read-only property). Maybe it isn’t possible with JXA, although I haven’t tested.

1 Like

I found out how to create the value with “estimated minutes” but not the column.

tell application “Keyboard Maestro Engine”

set pomodoroEvent to value of variable “pomSesCatAppKeyIntDurLoc”

set pomodoroCatKeyInt to value of variable “pomSesAppCatKeyInt” –
set pomodoroDuration to getvariable “pomSesApp__Duration”
end tell
tell front document of application “OmniFocus”

set theTask to make new inbox task with properties {name:pomodoroEvent, note:pomodoroCatKeyInt, estimated minutes:pomodoroDuration}

end tell