Replies: 3 comments 1 reply
-
Hi @BriseBolt! I'm Dosu and I’m helping the Trilium team. Trilium doesn't have a built-in way to automatically add the #archived label when you add #endDate, but you can achieve this with a backend script using the runOnAttributeChange event. Here's how you can set it up:
// This script runs when any attribute (label) changes on the note
if (attribute.name === "endDate" && !note.hasLabel("archived")) {
note.addLabel("archived");
} This will automatically add the #archived label whenever #endDate is added or changed on a note. You can find more details about scripting events and the API in the Trilium scripting documentation and backend script API. This approach is fully supported and can be targeted to specific notes or entire subtrees. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
I'll try that, but I'd like the script to perform more actions when adding the I would like the script to remove the What script could do this? |
Beta Was this translation helpful? Give feedback.
-
You can use a backend script like this, attached with the runOnAttributeChange relation: // This script runs when any attribute (label) changes on the note
if (attribute.name === "endDate") {
// Remove any #color label (regardless of value)
note.removeLabel("color");
// Add #color=slategrey
note.setLabel("color", "slategrey");
// Add #archived label
note.addLabel("archived");
} This uses the BNote API methods: removeLabel to clear any #color label, setLabel to set #color=slategrey, and addLabel to add #archived. Attach this script to the relevant notes or subtree using the runOnAttributeChange relation so it triggers when #endDate is added or changed. For more details, see the BNote scripting API and event scripting docs. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like trilium to automatically archive a note when I add the
#endDate
label to it. How do I configure trilium to automatically add the#archived
label after adding the#endDate
label?Beta Was this translation helpful? Give feedback.
All reactions