When I attempt the dataviewJS Query: const currentFile = dv.current().file.path; const…
- User
When I attempt the dataviewJS Query:
const currentFile = dv.current().file.path;
const pages = dv.pages("#Job") .where(p => !p.Applied && p.file.path !== currentFile) .sort(p => p.DJobPostDate);
dv.table(["Date Posted", "Note Title", "Applied"], pages.map(p => [ p.DJobPostDate, dv.fileLink(p.file.path), dv.el("input", "", { type: "checkbox", onchange: async (e) => { const file = app.vault.getAbstractFileByPath(p.file.path); if (!(file instanceof TFile)) return;
codelet content = await app.vault.read(file); let changed = false; // Update frontmatter Applied: false → true if (/^Applied:\s*false$/mi.test(content)) { content = content.replace(/^Applied:\s*false$/mi, "Applied: true"); changed = true; } // Update "- [ ] Applied" → "- [x] Applied" anywhere in the file if (/^- \[ \] Applied.*$/gim.test(content)) { content = content.replace(/^- \[ \] Applied(.*)$/gim, "- [x] Applied$1"); changed = true; } if (changed) { await app.vault.modify(file, content); } else { new Notice("No matching 'Applied' field or task found in " + file.name); } } }) ]));
I recieve a table with checkboxes where the Applied value is NOT true. However these boxes should reflect the state of the related note's Applied Value, if they are checked, the note should also be checked
- Assistant