Example of running a script on note content change. #7262
-
Hello and thanks for this great tool! I would like to run a script, when the contents of the note that I'm editing change. To do that I'm creating a
And, in another plain text note I'm defining this relation: However, when I edit my plaintext note, no |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @bergercookie! I'm Dosu and I’m helping the Trilium team. The reason your script isn't running is that the If you want dynamic frontend behavior (like showing a message when a note is activated or its content changes), you can create a JS Frontend note that extends In summary:
To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu , I've changed the type of my script note to
If I manually run it the console comes up and I see this message.
|
Beta Was this translation helpful? Give feedback.
You're not doing anything obviously wrong—your setup should work if the relation points to a JS Backend script and the note's content is actually being changed. However, the output of
api.log
is only visible in the UI log panel when you run the script manually; it won't show up for event-triggered scripts like those run via~runOnNoteContentChange
unless you check the backend logs (docs).For a more visible way to verify the trigger, use a side effect like creating a new note with
api.createTextNote
or modifying an attribute. For example:This will create a child note every time the event fires, mak…