Skip to content

api.getNote(<jsBackendNoteId>) Executes Note #9086

@MatthewColvin

Description

@MatthewColvin

Description

I have a custom widget that can run back end notes.
It uses api.runOnBackend() to help with this.

From the widget...

async function runBackendNote(noteId) {
    await api.runOnBackend(function(noteId) {
        // Working theory is that:
        // ISSUE: Just calling api.getNote just auto execs when the note is labeled as js backend 
        const note = api.getNote(noteId);
        if (!note) { 
            api.log(`Could not find backend note: ${noteId}`); 
            return; 
        }
        
        // This was a work around since there is no api.runNote I was using for a little while
        // but it ended up causing double script execution 
        // const script = note.getContent();
        // eval(script);
        
    }, [noteId]);
    console.log("runBackendNote finished for noteId:", noteId);
}

I validated this is due to the fact the note is labaled as a JS backend note. i.e. type=application/javascript;env=backend because if I just change to plan text the note is not ran when calling api.getNote().

Claude really really wants there to be a runNote(noteId) API which would really help with my use case.

Never the less I don't think the intention is for a getNote call to actually exectue the note if that is expected then feel free to just close this up.

TriliumNext Version

0.102.1

What operating system are you using?

Ubuntu

What is your setup?

Local + server sync

Operating System Version

Ubuntu 22.04

Error logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions