'm currently trying to create a customer call note template using Templater, and I’m running into some issues. I’ve designed the template so that I can prompt for inputs like customer name, call date, contact information, etc., using Templater’s tp.system.prompt() commands. I need these values to be filled in the frontmatter and throughout the note body for consistency.
<% tp.date.now(“YYYY-MM-DD”) %> - Call with [[<% tp.frontmatter.customer %>]]
Customer Information
Name: [[<% tp.frontmatter.customer %>]]
Contact: <% tp.frontmatter.contact_info %>
Call Details
Date & Time: <% tp.date.now(“YYYY-MM-DD”) %> <% tp.date.now(“HH:mm”) %>
Medium: <% tp.frontmatter.medium %>
Issues Discussed
Issue 1:
Issue 2:
Issue 3:
Resolution
Action 1:
Action 2:
Action 3:
Customer Feedback
Areas for Improvement:
Positive Points:
Reflection
What went well:
What could be improved:
Lessons Learned:
Linked Notes
The problem I’m facing is that while the frontmatter fields (customer , contact_info , call_date , etc.) are getting populated correctly, the prompts within the body of the note (<% tp.system.prompt(...) %> ) are not being evaluated as expected. Instead, these placeholders stay in the note without being replaced by the actual input values.
For example, after running the template, the frontmatter turns into:
The tp.frontmatter.something is to be used when inserting a template into an existing file. You can’t use it to refer to frontmatter you’re in the process of creating when executing the template in a newly created file.
All is not lost though, as you can store the result of the previous prompt and use that later on like in the following example:
<%*
const contact_info = await tp.system.prompt("Enter Contact Email or Phone")
const call_date = await tp.system.prompt("Enter Call Date (YYYY-MM-DD)")
_%><% "---" %>
contact_info: <% contact_info %>
call_date: <% call_date %>
<% "---" %>
Some more text
## Customer information
- Contact: <% contact_info %>
This template utilises a code block at the start to do all your prompting, before it actually inserts any text into the file. (One could assign output in that first code block by assigning stuff to tR, but I tried keeping it easy)
Using that somewhat strange <% "---" %> is a way to handle frontmatter fences without causing the template file itself to misbehave.
Just wanted to drop by and say that your solution worked perfectly for me! Not only did it solve my immediate problem, but looking over your code example really helped me understand better how Obsidian’s Templater works. I finally see how storing the prompts first and then using them later keeps everything much cleaner and more reliable.
I can’t thank you enough for the detailed explanation and that nifty trick with <% "---" %> to handle the frontmatter! Honestly, it all just clicked after seeing it written out like that.
Also, I have a quick question: How do you add those clean code blocks to the forum posts? I’d love to be able to format my future posts as neatly as yours. Any tips on that would be greatly appreciated!
Thanks again for taking the time to help. You’ve made my Obsidian workflow so much smoother!
Add more backticks… Typically when I present a query I enclose the query in four backticks, so that the three backticks of the query are preserved. (In order to present the example below I needed to use five backticks… )