Populate Template Placeholders
This script takes an OmniFocus project, replaces placeholder text with user entered strings, and adjusts all dates by some fixed interval to match a new start or due date that you enter. The new project appears at the end of your projects list. From there you can move it to the folder you want it to “live” in, or even move it into an existing project as a new action group.
It takes just three steps to add the script to your OmniFocus toolbar:
- In OmniFocus, choose Help → Open Scripts Folder.
- Drag the
Populate Templates Placeholderfile into the scripts folder.
- Control-click the toolbar and choose Customize Toolbar to add the script to the toolbar in OmniFocus.
To use, first you need to create a project template in OmniFocus. I use a top-level folder named Templates, marked dropped1, to hold my templates. Here is an example template:
Creating Your Own Template
- Create a project with actions for the steps you need to take each time you do the project. The example above lists the steps that I need to take when preparing to attend a conference and after I get home.
- Look for common words and phrases that will change each time you do the project. These will become placeholders. In the example above, «ConferenceName» and «ConferenceCity» are my placeholders. The script will replace placeholders with project-specific text when the template is populated. Placeholders are phrases without spaces, surrounded by double-angle quotation marks (also know as guillemets). On a US keyboard this punctuation can be typed with Option-\ and Option-Shift-. The placeholder markers can be changed by editing properties in the script.
- Next, list all of the placeholders in the last line of the note field of the project. In the example, you’ll see “«ConferenceName» «ConferenceCity»”. This allows the script to determine what values to prompt you for.
- If desired, set defer and due dates for the project and for any items within the project. Dates will be adjusted when the template is populated. Note, the project must have a defer or due date (or both) or the script will not set dates on the actions.2
- You can add a line to the note that begins “Due date is”. If that line is present, the script will include the line when prompting you for the new project’s due date. Note, the Due date is line must come before the placeholder line in the note.
Populating Your Template
Now when you’re ready to start a new project using your template, just follow these steps:
- Select the root item of the template project. In the example, that’s the “Attend «ConferenceName»” row.
- Click the icon for the script in the OmniFocus toolbar.
- When prompted, enter values for each of the placeholders.
- When prompted, enter a new defer or due date from the project.
- The script will create a duplicate of the project template with placeholders and dates filled it.
- Drag the new project to the proper place in your system.
1 In what could be considered a bug, projects inside dropped folders are not moved to the OmniFocus archive. However, such projects are also not shown in lists of active projects. So, keeping a template project in a dropped folder is a convenient way to hide the project in most lists while still keeping it around.
2 Gory details on dates:
- If the template project has a due date, then the user is prompted for a new due date. The difference between the two is the “slip time”, the amount by which the template will be slid forward in time to make the new copy.
- Otherwise, if the template project has a defer date but no due date, then the user is prompted for the new defer date. The difference between the two defer dates is the “slip time”.
- Finally, if there is neither a due nor a defer date on the project, then the project is copied but the dates aren’t changed.
When the template is copied to make a new project, all the dates are moved forward by the slip time if it exists. If it doesn’t exist, then no dates are changed.