mgmeyers/obsidian-kanban

[Bug]: Kanban V2 with Dataviewjs scripts / Moving files leeds to errors

Opened this issue · 0 comments

Describe the bug

Moving files leeds to errors

relevant part of the script, I think:

// Dynamically Determine the Current Folder
let currentFolderPath = "";
try {
    // First try to get the folder of the current file (works for saved notes)
    currentFolderPath = dv.current().file.folder; 
} catch (e) {
    try {
        // If that fails, try getting the folder from the active pane (works for unsaved notes)
        currentFolderPath = app.workspace.getActiveFile().parent.path;
    } catch (e) {
        // Fall back to root as a last resort if both fail
        currentFolderPath = "/";
    }
}
// Retrieve and filter pages within the determined folder
let pages = dv.pages(`"${currentFolderPath}"`)
    .where(page => page.file && page.tags && page.tags.includes(dimTag))
    .where(page => !('completed' in page) || !page.completed)
    .where(page => page.file.name != dv.current().file.name) // Exclude the current file itself
    .where(page => page['Projektstatus'] == desiredProjektstatus);

Expected Behavior

dataviewjs script should reload and work as intended.

When in edit mode:
image
it works, but as soon as I hit enter, it is gone. - see steps to reproduce

Steps to reproduce

  1. Add the following dataviewjs script to a board:

const dimTag = '#dim/8-Release';
const desiredProjektstatus = '01-new';

// Dynamically Determine the Current Folder
let currentFolderPath = "";
try {
    // First try to get the folder of the current file (works for saved notes)
    currentFolderPath = dv.current().file.folder; 
} catch (e) {
    try {
        // If that fails, try getting the folder from the active pane (works for unsaved notes)
        currentFolderPath = app.workspace.getActiveFile().parent.path;
    } catch (e) {
        // Fall back to root as a last resort if both fail
        currentFolderPath = "/";
    }
}

// Retrieve and filter pages within the determined folder
let pages = dv.pages(`"${currentFolderPath}"`)
    .where(page => page.file && page.tags && page.tags.includes(dimTag))
    .where(page => !('completed' in page) || !page.completed)
    .where(page => page.file.name != dv.current().file.name) // Exclude the current file itself
    .where(page => page['Projektstatus'] == desiredProjektstatus);



// Create table data (include file name if frontmatter properties are missing)
let tableData = pages.map(page => {
    const pageLink = page.file.link;
    const dringlichkeit = page.Dringlichkeit || "N/A"; 
    const wichtigkeit = page.Wichtigkeit || "N/A";
    return [pageLink, dringlichkeit, wichtigkeit];
});

// Display the table or an error message
if (tableData.length > 0) {
    dv.table(['Projekt', 'Dringlichkeit', 'Wichtigkeit'], tableData);
} else {
    dv.paragraph("No pages found matching the criteria.");
}
  1. Then move the file to a different folder
  2. See the error:

Error screenshot:
image

Relevant errors (if available)

No error available.
Adding this maybe helps:
//<% Math.round(Math.random()*10**15) %> (as I create these files with templater)

Operating system

Windows