How to show the newest note after using data.put

I am trying to write a plugin,but meet a problem. I used
await joplin.data.put(['notes', todoID], null, { body: "body note"})
to change the body of a note, but I could only see the old note after the code is executed. When I clicked another note and then clicked back to the note, the note body is the new one.
How can I refresh the note after using joplin.data.put() command?

You can use the replace command like I do on my plugin for the active note.

this command works fine if I choose the note and execute the code, but still one thing left: If I do not choose the note that I want to change but choose another one, the command will replace the selected note text. I tried to use openNote command like the code below to make the note selected,but failed.

await joplin.commands.execute("openNote",todoID);
await joplin.commands.execute('textSelectAll')
await joplin.commands.execute('replaceSelection', todo.body + "\n"+ finishedTask)

For the not selected notes use the put command and the select/replace command only for the selected note. Because only the actual selected note is not updated until you switch to another note and back again.

This is the problem. Both situations exist(select the note or not select the note at the first time). I tried these two solutions, and found that each solution will only solve one problem. Maybe I should consider to find out if the note is selected at the beginning, and choose to use different code.
Thank you!

Check in my code the updateNoteBody

1 Like

Exactly what I need!