Automatically assigning today's date as the value to #startDate after a note is created #7832
Replies: 4 comments 5 replies
-
|
Trilium doesn't have a built-in feature to automatically assign #startDate with today's date when you create a sub-note, but you can do this with a backend script. Create a new backend script note (type: JavaScript backend), then attach it to the parent note or subtree using the runOnAttributeChange relation. In your script, you can use something like: // This script runs when any attribute (label) changes on the note
if (!note.hasLabel("startDate")) {
note.setLabel("startDate", "TODAY");
}This will set #startDate=TODAY on notes that don't already have it. Trilium supports dynamic date expressions like TODAY, so #startDate=TODAY will always resolve to the current date when the label is set. For more details and examples, see this discussion and supported date expressions. If you want this to happen only for newly created sub-notes, you may want to refine the script to check for note creation events or use templates for new notes, but the backend script approach is the most flexible for automation. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
@dosu is right about needing to write a script, but is wrong about |
Beta Was this translation helpful? Give feedback.
-
|
@eliandoran The script doesn't create any labels or generate any dates. I only get a 500 error when I run the script. How do I fix this? |
Beta Was this translation helpful? Give feedback.
-
|
@SunriseWind if the parent note carries the attribute |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I would like the sub-notes I create to automatically assign the label #startDate with today's date as the value for that label. How can I do this?
Beta Was this translation helpful? Give feedback.
All reactions