Zotero.ItemFields undefined
Hi,
I tried to change an entry with a JS API. It looks like:
------------
var fieldName = "proceedingsTitle";
var oldValue = "63rg";
var newValue = "63rd";
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search;
s.addCondition(fieldName, 'is', oldValue);
var ids = s.search();
if (ids) {
for each(var id in ids) {
var item = Zotero.Items.get(id);
var mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
item.save();
}
alert(ids.length + " items updated");
}
else {
alert("No items found");
}
--------
Yes, it's a copy-paste from https://www.zotero.org/support/dev/client_coding/javascript_api
When I run it I get the following message: "Exception: Zotero.ItemFields is undefined"
What am I doing wrong?
Thanks!
I tried to change an entry with a JS API. It looks like:
------------
var fieldName = "proceedingsTitle";
var oldValue = "63rg";
var newValue = "63rd";
var fieldID = Zotero.ItemFields.getID(fieldName);
var s = new Zotero.Search;
s.addCondition(fieldName, 'is', oldValue);
var ids = s.search();
if (ids) {
for each(var id in ids) {
var item = Zotero.Items.get(id);
var mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
item.save();
}
alert(ids.length + " items updated");
}
else {
alert("No items found");
}
--------
Yes, it's a copy-paste from https://www.zotero.org/support/dev/client_coding/javascript_api
When I run it I get the following message: "Exception: Zotero.ItemFields is undefined"
What am I doing wrong?
Thanks!
This is an old discussion that has not been active in a long time. Before commenting here, you should strongly consider starting a new discussion instead. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
Upgrade Storage
Have to say that I'm not very familiar with JS and the developer environment in Firefox.
Thanks very much!