I ask the help of respected experts with the templater plugin

Good day dear experts!
In my workflow I am using the Templater plugin
when creating a note using a template, a link is created in the note to another note, which is also automatically assigned a template.
and for me it works very well!
But there is a problem when a note with this name has already been created, then Templater, according to my script, creates note 1 instead of note
is it possible to make it so that before creating the second template by reference
there was a check - if the note name exists, then he would simply make a link and not create a note, and if the note does not exist, then he would make a link and insert a template

here is my script
template name = template
note name = the name of the note that is generated from the template

[[<% (await tp.file.create_new(tp.file.find_tfile("template name"), "note name")).basename %>]]

How about something like this:

const note = "note name";
const template = "template name";
if (!tp.file.find_tfile(note))
   await tp.file.create_new(tp.file.find_tfile(template),note);
[[<% note %>]]
1 Like

Thank you! This works just fine! You helped me a lot!

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