What I’m trying to do
I am attempting to use a hybrid of Templater and Dataview code to retrieve a YAML value from a file called “PROJ_INFO” from the parent directory of the current note. I am attempting to retrieve two YAMLS “PROJ_ID” and “PROJ_NAME”
Things I have tried
Here is the current code set I have been experimenting with but it comes back with an error stating “PROJ_NAME” is undefined. I am hoping someone sees something I may be overlooking.
// Get current file’s path and move up one folder
const fullPath = tp.file.path().split(“/”);
fullPath.pop(); // Remove current filename
fullPath.pop(); // Go up one folder
const parentFolder = fullPath.join(“/”);
const projectInfoPath = parentFolder + “/PROJ_INFO.md”;
tR += **Debug Info:** Recognized projectInfoPath → \
${projectInfoPath}`\n; console.log(
Debug Info: Recognized projectInfoPath → ${projectInfoPath}`);
// Check if dv (Dataview API) is available
if (typeof dv === “undefined”) {
tR += “ Error: Dataview plugin not available.\n”;
} else {
// Correct usage: vault-relative string, not wikilink
const projectInfo = dv.page(projectInfoPath);
if (!projectInfo) {
tR += ❌ Could not load PROJ_INFO.md at: \
${projectInfoPath}`\n`;
} else {
const projName = projectInfo.PROJ_NAME || “ PROJ_NAME not found”;
const projID = projectInfo.PROJ_ID || “ PROJ_ID not found”;
tR += `✅ Loaded from: \`${projectInfoPath}\`\n`;
tR += `**Project Name:** ${projName}\n`;
tR += `**Project ID:** ${projID}\n`;
}
}