Hi – I’ve been using Obsidian for several months now to manage notes related to different projects I have.
The forum here has been invaluable to me, and I thought I’d make this post on what I’m currently troubleshooting. Maybe some of you could help.
What I’m trying to do
When I start a new project, I use QuickAdd to create a new “Project Overview” note from my “Project Overview” template. I use QuickAdd because I like being able to use {{VALUE: Project Name}} and {{VALUE: Collaborator}} – then those values are inserted into the Title, YAML, and some dataview tables I have setup to track progress and show related notes. I also have QuickAdd dynamically create a new project folder – “Create in Folder” Spaces>Projects>{{DATE: YYYY-MM}} {{VALUE: Collaborator}} - {{VALUE: Project Name}}
Then, I can keep all of my meeting notes and related project files within that project subfolder. I’ve been using QuickAdd to create meeting notes from template utilizing the same {{VALUE: }} prompts. So I end up entering the Project Name, Collaborator, etc. again; and if I misspell something…
So…
What I’d like to do is to be able to create a new meeting note that pulls the Project YAML property from the Project Overview note and populates that value in a new note and applies my Meeting Note template. Then move that note into the correct folder automatically.
I was working more on the modified code and thought I’d share it.
<%*
const dv = this.app.plugins.plugins["dataview"].api;
// Get the current file (Project Overview note)
const curr = tp.config.target_file;
const dvCurr = dv.page(curr.path);
// Extract the values of "Project" and "Artist" from YAML frontmatter
const projectValue = dvCurr.frontmatter["Project"];
const artistValue = dvCurr.frontmatter["Artist"];
// Check if both values exist
if (!projectValue || !artistValue) {
window.alert("The Project Overview note is missing required metadata.");
return;
}
// Prompt the user for Meeting Attendees
const attendees = await tp.system.prompt("Meeting Attendees (comma-separated)");
// Generate the new file name in the desired format
const currentDate = new Date();
const formattedDate = currentDate.toISOString().slice(0, 10); // Format as YYYY-MM-DD
const newFileName = `${formattedDate} ${projectValue} Meeting Note`;
// Derive the project folder path from the active file's path
const activeFilePath = curr.path;
const projectFolderPath = activeFilePath.split("/").slice(0, -1).join("/");
// Generate the path for the new meeting note
const meetingNotesFolderPath = `${projectFolderPath}/${projectValue} Meeting Notes`;
const filePath = `${meetingNotesFolderPath}/${newFileName}.md`;
// Define the content for the new note with inherited metadata
const content = `---
class: Meeting Note
Project: ${projectValue}
Artist: ${artistValue}
Date: ${formattedDate}
---
# ${newFileName}
Attendees:: ${attendees}
### Summary
## Notes
## Reflection
`;
// Create the new note in the specified subfolder
const baseFolder = app.vault.getAbstractFileByPath(meetingNotesFolderPath);
await tp.file.create_new(content, `${newFileName}.md`, true, baseFolder);
_%>
Right now, I’m getting back this error in console (which might mean it’s unable to find the active file?):
To test the code, I open a project overview note for a project I’m working on, launch Command Palette (CMD + P), and select “Templater: Create new note from template”. Then I select my test meeting note template which contains only the code I pasted above.