In this example we are going to extend the functionality of Task Manager showcase (which comes by default with Trilium) by adding a button in the Launch Bar () to create a new task automatically and open it.
Here we identify a note with the label#taskTodoRoot. This is how the Task Manager showcase knows where to place all the different tasks.
Normally this might return a null value if no such note could be identified, but error handling is outside the scope of this example.
const resp = api.createTextNote(todoRootNote.noteId, "New task", "")
We create a new child note within the to-do root note (first argument) with the title “New task" (second argument) and no content by default (third argument).
await api.waitUntilSynced();
Back on the client, since we created a new note on the server, we now need to wait for the change to be reflected in the client.
await api.activateNewNote(taskNoteId);
Since we know the ID of the newly created note, all we have to do now is to show this note to the user.