I’d like to store receipts in my vault, and have my daily notes show a list of receipts from that day at the bottom of the note. My notes are named in the format YYYY-MM-DD_ddd, and my receipts (all PDFs) use the name format “YYYYMMDD - .pdf”. I have this dataviewjs code that works when included directly in a daily note:
```dataviewjs
const filename = dv.current().file.name
let grabdate = filename.split("_")[0]
let grabparts = grabdate.split("-")
let year = grabparts[0]
let month = grabparts[1]
let day = grabparts[2]
let newdate = year + month + day
const folderpath = '\_Resources/Receipts'
const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes(folderpath) && file.name.includes(newdate))
dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
```
What I’d like to do is create a template (“Journal Metadate (Template)”) that contains the header ‘Documents’, followed by the code which would display the list of matching files. I’d then append the following to the end of every daily note:
![[Journal Metadata (Template)]]
This leaves the daily note markup much cleaner (easier to read in other systems) than if I were to include all the code.
When I try this, I get the header “Documents”, but it doesn’t show any results from the code. I also tried this in the template:
<%*
tR += \```dataviewjs
const filename = dv.current().file.name
let grabdate = filename.split("_")[0]
let grabparts = grabdate.split("-")
let year = grabparts[0]
let month = grabparts[1]
let day = grabparts[2]
let newdate = year + month + day
const folderpath = '\_Resources/Receipts'
const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes(folderpath) && file.name.includes(newdate))
dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
\```
%>
But it just shows that exact code in the daily note, not the results of the code. I feel like I must be close, can anyone see where I’m going wrong? Bonus points if you can improve the coding I have, which is based on my copy/paste knowledge of dataviewjs.