Hi everyone! I have this helpful little bit of code that helps me stay organized. It’s in my daily note, and what it does is search for files in a folder that match the date of my daily note.
I often use things like DB Folder or other database tables to add those notes to the calendar in bulk. When I remove them from the schedule using the calendar button, however, it leaves a “” in the metadata of the note (date: “” ) instead of leaving it blank.
This causes the code in my daily note to generate an error.
These “” are annoying AF to clear out and are sometimes hard to find (I have several thousand files).
Is there a line of code I can add to this to just make it accept date: “” as an acceptable piece of metadata, or ignore the “”?
Here’s my code:
const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;
dv.table(["File Name", "Shared"],
await Promise.all(
dv.pages('"Social Media Activities"')
.where(p => p['date']?.toFormat("yyyy-MM-dd") == dv.current().file.day.toFormat("yyyy-MM-dd"))
.map(async p => [
p.file.link,
await f(dv, p, "shared")
])
))
I did try adding an exception (lol), but it didn’t work. I admit I don’t really know what I’m doing:
const { fieldModifier: f } = this.app.plugins.plugins["metadata-menu"].api;
dv.table(["File Name", "Shared"],
await Promise.all(
dv.pages('"Social Media Activities"')
.where(p => p['date']?.toFormat("yyyy-MM-dd") == dv.current().file.day.toFormat("yyyy-MM-dd")!= (""))
.map(async p => [
p.file.link,
await f(dv, p, "shared")
])
))
The error is:
Evaluation Error: TypeError: p.date?.toFormat is not a function
at eval (eval at (plugin:dataview), :6:30)
at Array.filter ()
at Proxy.where (plugin:dataview:8259:39)
at eval (eval at (plugin:dataview), :6:8) blahblablah…
Thanks so much.