You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, I would like to thanks @zadam for his work with Trilium, its amazing.
Second, I need help to improve a script.
The start scenario is a render note ("Amazon_search") with an html note asociated ("amazon_html").
The functionality is simple, you can write a product name in the form and, clicking the submit button, it opens a browser window with the specified search.
The code is simple too (for a newbie like me ;) ).
I´m asking for help to improve this code. My need is creating a new note everytime I do a search.
The new note should have the next features:
It mus be children of the search note.
Its name should be created with a timestamp and the search term introduced in the form.
I have been studying the code used to create a new button and I think the idea is very similar, only changing
the element that triggers the action. My aproach is the next code, but I dont know if its correct and
if I put it on the script it doesn´t work.
async const createAmazonNote=() => {
// creating notes is backend (server) responsibility so we need to pass
// the control there
const newAmazonNote = await api.runOnBackend(() => {
const response = api.createNewNote({
parentNoteId: 'id_Amazon_search',
title: "date+hour+Amazon001",
content: "",
type: "text",
isProtected: false
});
const templateNote = api.getNotesWithLabel('Amazon_template')[0];
//add template to new note
response.note.setRelation('template', templateNote.noteId);
return response.note;
});
// wait until the frontend is fully synced with the changes made on the backend above
await api.waitUntilSynced();
// we got an ID of newly created note and we want to immediatelly display it
await api.activateNewNote(newAmazonNote);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
First of all, I would like to thanks @zadam for his work with Trilium, its amazing.
Second, I need help to improve a script.
The start scenario is a render note ("Amazon_search") with an html note asociated ("amazon_html").
The functionality is simple, you can write a product name in the form and, clicking the submit button, it opens a browser window with the specified search.
The code is simple too (for a newbie like me ;) ).
I´m asking for help to improve this code. My need is creating a new note everytime I do a search.
The new note should have the next features:
I have been studying the code used to create a new button and I think the idea is very similar, only changing
the element that triggers the action. My aproach is the next code, but I dont know if its correct and
if I put it on the script it doesn´t work.
Thank you for your attention.
Beta Was this translation helpful? Give feedback.
All reactions