I have solved my issue and possibly also @gianx issue.
Im using the buttons plugin to create a new note from a template with backlink to parrent file by the push of a button.
The buttons code for a specific case note has the following syntax in my case template file.
name case_note
type note(tmp-<%tp.file.title%>) template
action case note 1
templater true
This ensures that the button creates a note called tmp-<CASEID>
from a template called case note 1
which will pull the CASEID
from the title and insert it as a backlink. In addition Im passing metadata (a field called titel
) from the parent not to the child via DataviewAPI.page
object.
case note 1
templater file:
<%*
const dv = this.app.plugins.plugins["dataview"].api;
let refnr = tp.file.title.slice(4,10);
const fooMeta = DataviewAPI.page(tp.file.find_tfile(refnr).path)
let new_titel = tp.date.now("YYYY-MM-DD_HHmm")
tp.file.rename(new_titel)
await tp.file.move("daily notes/" + tp.date.now("YYYY") + "/" + tp.date.now("MM") + "/" + new_titel)
-%>
---
type: case_note
titel: <% fooMeta.titel %>
---
summary::
refnr:: [[<%refnr%>]]