getting parent item in a group library

20 views
Skip to first unread message

EluisiveOctopus

unread,
Jun 13, 2022, 2:52:28 PMJun 13
to zotero-dev
Hello,
API question

I'm writing a plugin with code similar to the following -- which is stolen from this plugin: https://github.com/UB-Mannheim/zotero-ocr/blob/master/chrome/content/zoteroocr.js#L98

It works when I have a pdf selected on my personal 'My library' sub-collection, but when I use it on something selected in a sub-collection in my 'group library' I get errors like (below).  The errors happen with the zotero-ocr plugin as well so maybe I shouldn't be basing my logic off that plugin and that's my problem.

[JavaScript Error: "Parent item 1/4Q5DY97J not found" {file: "chrome://zotero/content/xpcom/data/item.js" line: 1537}]

Is there something obvious that I'm doing wrong here?

Thanks!
basic code is the following (error above):


let basestr = "myfile"';
let item = Zotero.getActiveZoteroPane().getSelectedItems()[0];
let parentitem = Zotero.Items.get(item.parentItemID);
yield Zotero.Attachments.importFromFile({
file: basestr + '.pdf',
parentItemID: parentitem.id
});
thanks!
Reply all
Reply to author
Forward
0 new messages