From Daily Note, Create a New Note with a Template

I feel like I am super close, but I’m at a loss on what I should do next

What I’m trying to do

As a user of a Daily Note
I would like to simplify my Standup notes by having access to create a new note populated from Templates/StandupTemplate, from within my Daily Note
I’d like Standup notes to be

  • linked to my Daily Note
  • populated with a pre-defined template
  • opened when I click a create button (or something like that)
  • assigned a filename like Standup 2024-01-30-Monday
    So that I can have meeting notes linked in my Daily Note opened a new note, in a new tab, with a single click

Things I have tried

An Attempt

I tried embedding a link that doesn’t exist yet. This would give me the ability to only create the Standup note file on days I want. Ya know, like only on work days

![[Standup <% moment().format('YYYY-MM-DD-dddd')]]
No luck here. I mean, this is part of the functionality I was hoping for, but lacks in having a pre-defined template

Part Way There?

There was a half step before the next attempt, where I tried to just use the file path to the template, but that didn’t seem to work

Another Attempt

Looking at docs, creating a new file is possible
It should be tp.file.create_new(template, filename, open_new, folder)

I’m unsure what I am doing wrong here, but it seems like I’ve assigned arguments appropriately.

I tried a few variations before getting what I think is the right way to do it. Still not much luck with

<%* await tp.file.create_new(
                             tp.file.find_tfile("Templates/StandupTemplate"), 
                             moment().format("YYYY-MM-DD-dddd"), 
                             true) %>

Still, the console is showing

Templater Error: Template parsing error, aborting. 
 Destination file already exists!

and

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'path')
    at eval (plugin:templater-obsidian:3744:90)
    at Array.find (<anonymous>)
    at Templater.get_new_file_template_for_folder (plugin:templater-obsidian:3744:59)
    at Templater.on_file_creation (plugin:templater-obsidian:3764:47)

For reference, the only folder I have is Templates. Everything else is free-range

Hello, I use the Templeter “create note” button in my daily note.

The templater create note I use

  • creates a note
  • With a set template
  • saves it to a specified folder

And then in my daily note I have a dataview quiery that can show what is in that folder

would that do what your after if so I can paste it in this

The issue I had when setting it up was in putting the date in the title. So I got round that by adding the rename templater command in my template.

There must be a way to do it in the button itself but I could not figure it out

That does sound almost exactly like what I was trying to do.

That’s a nifty workaround. I could definitely handle that

If you wouldn’t mind sharing, I’d love that. I’m excited to see how you did it

Looking at my obsidian I am using the “Meta-Bind” Plugin to make buttons.
Link to button doc

  1. Here is the meta-bind snippet
style: primary
label: Standup Note
actions:
  - type: templaterCreateNote
    templateFile: "templates/Standup Note.md"
    folderPath: Standup_Notes
    fileName: "Standup Note"
  1. Add this templater command in your template for Standup Notes

/// This renames the file adding the date as the template is applied
<% tp.file.rename(tp.date.now("YYYY-MM-DD ddd [ Standup Note] ")) %>

  1. In my daily note and weekly notes I have lots of different “dataview queries” to show contents of a folder

I put meta data in each note so I can call different things with a dataview.

image

If I wanted to just see the standup notes for a given week I would use the “week_year” from my front-matter

LIST
FROM "Standup_Notes"
WHERE file.week_year = this.file.week_year
SORT ASC

Hard to describe am a noob and just bodging through with this

Any questions feel free to ask

Thanks
wintermute_obs

1 Like

2 Likes

This was so very helpful. Thanks Wintermute_obs!

It took me a moment to put all the things together but I now have a wonderful inline button BUTTON[standup-btn]!!! And I think many many new doors have been unlocked with this new information.

Your welcome

1 Like

I did see the docs, but I was missing some of the surrounding context. For posterity, here are the bits I was unsure about.

How, or where, do I make the button or use the meta bind snippet?

There’s options! Okay, they’re really the same thing. There’s just different ways to get there

  • From the command palette, Meta Bind: Open Button Builder is what you want

OR

  • From settings > community plugins > meta bind > button templates > edit templates

Either way, make note of the [unique] ID you’re giving to the button. It’ll get used later to make the button

What code did you use for the button template?

I used the button building form in settings to create this:

label: Standup
icon: ""
hidden: false
class: ""
tooltip: ""
id: standup-btn
style: primary
actions:
  - type: templaterCreateNote
    templateFile: Templates/StandupTemplate.md
    folderPath: /
    fileName: ""
    openNote: true

Where do I put the templater code for renaming the file?

It doesn’t matter where in the file, but you’ll but it in the template the button is meant to create. When I put it on it’s own line at the top of the file, the code did it’s job but there was an empty line for no good reason. So, I moved the code to the end of another line. Good bye extra lines

Here’s how to add a button

This will allow other buttons on the same line aka inline. Instead of button-id, give the id you made in the button template

BUTTON[button-id]

mine looks like BUTTON[standup-btn]

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