When note created, embed to the other note using Templater and QuickAdd plugins

I spend a few hours trying to understand documentation (I’m not really good at it), but finally found out how to run QuickAdd from inside the Templater’s template. Since we can set up folder templates and startup templates, it will allow us to run QuickAdd automatically. For example, every time a note is created in specific folder, we can automatically write some info about it a different note (it may be a link, some metadata or whatever).

Don’t know if somebody has come with this solution already, but in case someone interested here is my setup. In my case I wanted to make it so every time I create a daily note (via the Daily Note plugin or Calendar, or by clicking on links), the “Log” section of this note would be automatically embeded in enother note, called “Journal”, so I can see all my daily logs in one place. At first I wanted to do this with Dataview, but Dataview don’t work very well with embeds, so I decided to look for another way. I know a little bit of coding, but not enough to write complex scripts, so I wanted something simple.

So first I went to the QuickAdd plugin and set up a capture choice, calling it “Embed to journal”. In the capture setting I wrote the name of the file I want capture to, picked “Write to bottom of file” option and in “capture format” field I wrote {{VALUE:embed}}.

Then in the template for my daily note I wrote this:

<%*
await app.plugins.plugins.quickadd.api.executeChoice('Embed to journal', {embed: "![[" + tp.file.title + "#Log" + "]]"});
%>

### Log

### Some other section
Some other stuff

(My actual daily note is more complex then this, I just simplyfied it here).

This template is set up as my daily template in Daily Note plugin, but just in case I also went into the Templater’s setting and set it up as the folder template for my daily notes folder.

Now every time the note is created and template is applied, QuickAdd plugin also runs, and embed is captured into my journal note.

4 Likes

Stolen! thank you. So far my only use of the QuickAdd API via Templater was to summon the AI assistant.

Here is a version with a small tweak: each embed is preceded with a date in a clean format ↓

<%*
const date = tp.date.now("dddd D MMMM", 0, tp.file.title, "YYYY-MM-DD"); 
// make the first letter uppercase
const modDate = date[0].toUpperCase() + date.slice(1);
await app.plugins.plugins.quickadd.api.executeChoice('insérer dans le journal', {embed: "## " + modDate + "\n![[" + tp.file.title + "#Journal" + "|clean no-h lk-hvr]]"});
-%>