Keyboard shortcut

I hate to admit it :-) but I’m not succeeding in getting a task’s Due Date bumped by eg 2 days. The recipes for bumping a javascript Date object by 2 days - as found on the web - give bizarre results.

Would someone mind posting a fragment for bumping a task’s due date by, say, 2 days? And I can take it from there. It’s literally, given a task object in a working plug in, bumping its Due Date. (I’ve got the plug in code otherwise working.)

Thanks!

Sure. Paste this code inside a text file with .omnifocusjs extension. I should this code only show the plug-in available if every task in the selection has a due date.

/*{
	"type": "action",
	"author": "unlocked2412",
	"version": "0.1",
	"description": "Bump a task's due date by 2 days"
}*/
(() => Object.assign(
    new PlugIn.Action(selection => {

        // main :: IO ()
        const main = () => {
            // addDays :: Int -> Date -> Date
            const addDays = n => dte => {
                const dte2 = new Date(dte);
                return (
                    dte2.setDate(n + dte.getDate()),
                    dte2
                );
            };

            const
                ts = selection
                .tasks
                .filter(task => null !== task.dueDate);

            return ts.map(task => {
                const
                    taskDate = task.dueDate;
                return (
                    task.dueDate = addDays(2)(taskDate),
                    task
                )
            })
        };

        // MAIN -----------------------------------------
        return main()

    }), {
        validate: selection =>
            selection
            .tasks
            .filter(task => null !== task.dueDate)
            .length > 0
    }
))();
1 Like

Thank you. Will paste and then dissect.

Update: Works nicely, thank you!

1 Like

That looks very complicated. Is there no such basic functionality in the app itself?

I’m not really into scripting my todo environment.

Form.Field.Option gave me a “pick one from” list. It is a drop down list in Mac OS but not in iOS.

I also note that the share sheet lists the plugin on iOS but not iPad OS. I don’t know if that’s to be expected.

That’s certainly not expected. I can’t reproduce the problem in my iPad.

And then the plug-in seemed to fall off the share sheet on iOS when I tried to drag it too far up the share sheet - in edit mode. Strange. The plug-in is still installed and still working - on Mac, iPhone, and iPad. It also is in the toolbar on Mac.

I should probably copy the code into a new plug-in .omnifocusjs file and see what happens.

I’m reading all the replies but I guess the answer to my question is: No?

I mean do you know how this works in Things? It’s built in, I press Command-S and then I get a window like this where I can also type in free form numbers, days, deltas, whatever.

Screenshot 2021-05-09 at 22.51.07

After seeing this, I switched back to Things and couldn’t be happier.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.