-
I am building a script to add notes based on a json file. Once the json data is created as a new note through the GUI or by scripting using createDataNote(), how can I refer to it from my script, located in a different note? The json file is quite large, so storing it alongside the script in the same note is not practical. Is there a way to 'import' the content of a data note by scripting? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Sure, the trivial way is to just hardcode the note ID into the script: const dataNote = api.getNote('bMY492A20J2L'); // hardcode noteId
const json = dataNote.getJsonContent(); A nicer variant is to define a relation from your script note to the data note, e.g. const dataNote = api.currentEntity.getRelationTarget('dataNote');
const json = dataNote.getJsonContent(); |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply! I ended up using the following: I am finding myself debugging a lot of backend scripts and the api.log() methd definitely has its shortcomings. Do you have a guide to describe how to setup the environment to easily step through backend code? I suspect I should install the backend separately as described here, but any other recommendation that have made your life easier as you go through the backend code? |
Beta Was this translation helpful? Give feedback.
Sure, the trivial way is to just hardcode the note ID into the script:
A nicer variant is to define a relation from your script note to the data note, e.g.
~dataNote=...
and then access it like this: