New Draft with Template

If you have defined more than one template the New Draft with Template action provides a menu from which you can choose the template to use when creating a new draft. But, if several templates have the same first line, say [[title]] then the menu doesn’t help much. Does anyone have a way to create a name for a template that is not the first line of the template draft?

The specific use case: A researcher is taking notes. Each first line should be the title of the note. But the information recorded will vary depending upon whether the note is drawn from a book, an oral interview, a legal case, or a personal observation (say of a painting or building), etc.

The prompt that shows the list of templates to choose from just uses their titles because that’s how the action was written. You can readily edit the action’s JavaScript to show any other part of each template instead (like the second or third line, or whatever you use to distinguish between them).

It just depends what your own personal templates look like.

The script may not be that approachable if you are not familiar with coding, but it’s not terribly difficult to alter. The line in the example New Draft with Template action which sets the content of the new draft is:

d.content = d.processTemplate(template.content);

In this case the d variable is the new draft that has been created, and the template is the variable holding the template draft. The processTemplate part is what evaluated tags in that template, so timestamps and what not get expanded.

Perhaps the simplest way to get what you are describing is to keep putting the name of the template in the first line of the template, but remove that line when creating the new draft from the template. Changing the line above to the below would accomplish this…

let templateLines = template.lines; // get lines of template as array
templateLines.shift(); // remove first line
let templateContent = templateLines.join("\n"); // re-join lines without first one
d.content = d.processTemplate(templateContent);

Then you would still be selecting templates based on the name you put in the first line, but the first line would be omitted when creating the new draft with the action.

Thanks! Works great.