Missing information about the unique fieldID

15 views
Skip to first unread message

Michael Jungnickl

unread,
May 14, 2019, 10:50:14 AM5/14/19
to zotero-dev
Please do update the documentation ! 

Have a look at the "LibreOffice Plugin Protocol" webpage. 
There stands: 

fieldID                    A unique identifier corresponding to this field. 

But it's not unique. The fieldIDs are changed sometimes. 

This is the case in this sample: 
- Insert a few citations. 
- Insert the bibliography. 
- Then insert again a citation. 

Every time, a new citation is inserted into a document with an existing bibliography, some fieldID values must be updated. 
The field with the bibliography data must have the largest value N as fieldID. 
All citations have fieldIDs in the range [0...N-1]. 
The number N is equal to the count of all fields (citations + bibliography). 

LibreOffice does it, by inserting new citations with fieldID 0. 
In this case all fieldIDs of the citations are changing too. 

Adomas Venčkauskas

unread,
May 20, 2019, 5:40:03 PM5/20/19
to zotero-dev
The documentation isn't wrong. The integration plugin needs to return unique IDs for a single transaction initiated by the plugin and completed when Zotero issues "Document_complete". The IDs may change in between transactions. 

Michael Jungnickl

unread,
May 21, 2019, 4:38:27 AM5/21/19
to zotero-dev
The important thing: The field with the bibliography data must have the largest value N as fieldID. 

Adomas Venčkauskas

unread,
May 21, 2019, 4:56:23 AM5/21/19
to zoter...@googlegroups.com
On Tue, 21 May 2019 at 11:38, Michael Jungnickl <jung...@softmaker.de> wrote:
The important thing: The field with the bibliography data must have the largest value N as fieldID. 

That is not true. You can insert the bibliography anywhere you want, whether it's at the beginning or the end of the document, is up to the user (and the plugin implementation).

Michael Jungnickl

unread,
May 21, 2019, 5:52:07 AM5/21/19
to zotero-dev
Yes this is true about the placement of the bibliography within the document. You are right. 

But I talk about the fieldID value of the bibliography here. That's a different thing. 

I noticed that Zotero writes the bibliography data into the buffered field with the largest fieldID.
Buffered means, that I keep a listing with the field structures as array in memory. 
Changed field structures are written to the document finally. 

Michael Jungnickl

unread,
May 21, 2019, 5:56:12 AM5/21/19
to zotero-dev
Now I add a sample, for your understanding: 

Insert a citation => fieldID = 1
Insert the bibliography => fieldID = 2
Insert a citation again => fieldID = 3 (0 in LibreOffice which avoids the bug)

Update the bibliography now. 
Zotero uses the fieldID == 3 of the second citation. 

Adomas Venčkauskas

unread,
May 21, 2019, 6:12:50 AM5/21/19
to zoter...@googlegroups.com
Ok, I took a look again and that is what our LibreOffice implementation does. More specifically, the return data of the `Document_getFields` includes a list of field IDs, where the bibliography is always the last field number. These are implementation specifics to the LibreOffice plugin and your implementation does not have to follow them. For the record, the documentation specifies that fieldID can be a an absolutely random String or Number. This is correct. You do not have to mimic what our plugin does, you just have to ensure that when you return a list of fieldIDs from "Document_getField" they are in the order of appearance in the document and if you return [4, 3, 2, 1] that means that when Zotero invokes `Field_getText("docID", 4)` you will return the text of the first field that appears in the document. In this case 3 should return the second, 2 the third and so on.

Michael Jungnickl

unread,
May 21, 2019, 7:12:24 AM5/21/19
to zotero-dev
Thank you very much. 
Reply all
Reply to author
Forward
0 new messages