setCollection with javascript api doesn't work
Hi,
I have a perl script that used to work to export (from the command line) either the whole library or a single collection as a bibtex file. While the whole library still works, selecting a single collection does not.
In particular, I run something like this to get just the 3rd collection:
var collections = Zotero.getCollections();
var collection = collections[2];
translatorObj.setCollection(collection,1);
but when I run the translator, it still returns the whole library. This is the whole code (I am testing it using MozRepl):
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath('/tmp/tmpfile.txt');
var zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
var translatorObj = new Zotero.Translate.Export;
var collections = Zotero.getCollections();
var collection = collections[2];
translatorObj.setCollection(collection,1);
translatorObj.setLocation(file);
translatorObj.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4');
translatorObj.setLibraryID(null);
translatorObj.translate();
Thanks,
Jason
I have a perl script that used to work to export (from the command line) either the whole library or a single collection as a bibtex file. While the whole library still works, selecting a single collection does not.
In particular, I run something like this to get just the 3rd collection:
var collections = Zotero.getCollections();
var collection = collections[2];
translatorObj.setCollection(collection,1);
but when I run the translator, it still returns the whole library. This is the whole code (I am testing it using MozRepl):
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath('/tmp/tmpfile.txt');
var zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
var translatorObj = new Zotero.Translate.Export;
var collections = Zotero.getCollections();
var collection = collections[2];
translatorObj.setCollection(collection,1);
translatorObj.setLocation(file);
translatorObj.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4');
translatorObj.setLibraryID(null);
translatorObj.translate();
Thanks,
Jason
-
dstillmanedited September 11, 2016Better to post technical questions to zotero-dev. Also be sure to say what version of Zotero you're referring to.
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.