Populate Template Placeholders Script Automation?

Hi @jon123!

  1. Definitely possible! In the createFromTemplate.js file, just change return selection.tasks.length == 0 && selection.projects.length == 0; (line 41) to return true and this should achieve what you want.

  2. My approach to this was to set defer/due dates waaaay into the future so they didn’t show in Forecast etc and then they are included in a Hidden folder which includes a few other ‘projects’ and is already hidden from my perspectives anyway. I prefer this because it’s easier to go in and make changes to the templates when they are available than when they are dropped (which is my main motivation for keeping them in OmniFocus rather than somewhere external e.g. in TaskPaper format). I actually want to update the script to allow the due/defer dates to be specified in the notes rather than on the tasks themselves to get around exactly this problem - but with a 9-week-old in the house it might not be anytime soon! 😂

1 Like

Thanks Kaitlin! I agree on your approach for point #2, I’m going to switch over to that!

Is there a way to automate the defer date so that it is 2w prior to the template’s start date? I tried putting «start date»-2w in the Project’s defer date but that didn’t seem to work.

Hi @rubinjm,

I’m not 100% sure I follow what you’re trying to achieve, sorry! Perhaps you could clarify a little further?

The dates are all shifted relatively. So if you want, for example, a defer date that is two weeks before the due date (which you then set using the prompts) then you would set an (arbitrary, probably far in the future) due date on the template, and a defer date two weeks before that.

If you want the projects to have a particular defer date, would you not just set that directly as the defer date in the project? If there is no due date that will be used.

Sorry if I’m being obtuse and missing something obvious!

I don’t think that the defer dat can be set to before the start date of the project via scripting.

I remember trying to do something like this with Editorial and Taskpaper for a project to conduct an audit with the Audit itself at the centre of the project with the prep before and wrap up afterwards, but in the end I had to base it all off the end date of the project rather than the date of the audit.

Idk if this might be helpful, but this is my variation on the template idea.

It operates a little differently:

You keep templates within Omnifocus rather than somewhere else. This carries the benefits of not having to go update template files all the time when you update your omnifocus layout and being able to easily edit templates (without having to learn anything about taskpaper).

It uses a convention of what. I call a ‘predicate date.’ Due to a limit, at least when I set this up, in Shortcuts the convention uses 01/01/2045 at 12:00AM. Set up your templates to center around that date and when the shortcut is run you enter the date to use. It’ll slip the dates to the one provided. If I specify that the predicate date for a template is 8/5/2021, then a date of 12/31/2044 becomes 8/4/2021 in the resultant project/action group.

If I had any experience at all with scripting I’d translate this into omnifocus automation but I wouldn’t have a clue. If anyone else has benefited from this method, though, of course I’d welcome it.