[Zotero 6.0.19][JavaScript API] How to attach a note to an item ? [Resolved]

edited August 23, 2023
Hi all,

I'm developing a tool, using the internal javascript tool in Tools->Developer->Run JavaScript, to import several Audio Recordings item in Zotero. I would like to add a Note to some of them. Here is briefly how my code look

```
let item = new Zotero.Item('audioRecording');
/* setting the creator and different fields of the item */

let note = new Zotero.Item('Note');
/* setting the content of the note */

/* Here I'd like to add 'note' as a child note of 'item' */

await item.saveTx();
await note.saveTx();
```
Since this topic is not covered by the succinct documentation of the API, I looked a bit in the source code and the forums but was not able to find anything relevant. I tried many functions and attributes in both ways (item.setAttachment, item.addAttachment, item.setChild, item.addChild, note.setParentItem, note.parentItem ...) but none exist or work.

If any of you know what function could do that, or which file of the source code should contain the definition the functions related to the creation and attachment of notes (I did not find anything useful in chrome/content/zotero/note.js), it would be greatly appreciated.

Thanks in advance,
Camille Vacher
Sign In or Register to comment.