Undefined values from templater

Hi all,

First of all, my apologies if this question is answered previously, or I’m making a mistake
I tried to find information about the issue before and finally, I don’t find anything related

What I’m trying to do

I’m trying to deploy a meeting template that ask me for some variables (Title, Meeting Status, Meeting Location). When I try to use the values of the variables in frontmatter into the body I retrieve undefined as result

for example:

<% tp.frontmatter.meeting_status %> shows undefined as a result.
<% tp.file.title %> shows untitled as a result

That’s the code for my template:

---
<%*
const title = tp.file.title
if (title.includes("Untitled")) {
const newTitle = await tp.system.prompt("File Name")
await tp.file.rename(newTitle)
}
-%>
creation_date: <% tp.file.creation_date("DD/MM/YYYY HH:mm") %>
creation_year: <% tp.file.creation_date("YYYY") %>
modified_date: <% tp.file.last_modified_date("dddd Do MMMM YYYY HH:mm:ss") %>
type: meeting
meeting_status: <% await tp.system.suggester(["Interna", "Externa"], ["Interna", "Externa"]) %>
meeting_location: <% await tp.system.suggester(["Virtual", "In Person"], ["Virtual", "In Person"]) %>
summary: ""
---


# [[<% tp.file.title %>]]

## Meeting Details:

- Meeting Status: <% tp.frontmatter.meeting_status %>
- Meeting Location: <% tp.frontmatter.meeting_location %>

When I apply the template, I see undefined in case of the value

Environment

OS: macOS Sonoma
Obsidian version: v1.4.16
Obsidian installer: v1.4.14
Templater plugin version: latest update (10/10/2023)

Things I have tried

  • I tried to reinstall the plugin wiht (no luck)
  • I tried to switch off and switch on the plugin (no luck)

Thanks in advance
Regards

You must give Templater “some time” to process the changes.

  • You need to use title or newTitle to write the H1.
  • Save the meeting status suggester’s return value in a variable in the execution command block above, i.e., const meetingStatus = await tp.system.suggester(["Interna", "Externa"], ["Interna", "Externa"]), and use that variable to set the frontmatter key meeting_status and the list item - Meeting Status: <% meetingStatus %>.

In a nutshell: First collect all the necessary information and then “distribute” them later accordingly. :wink:

1 Like

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