Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
dev:client_coding:javascript_api [2018/09/05 18:06] – [Managing citations and bibliographies] Add brackets for getNote() zuphilip | dev:client_coding:javascript_api [2018/09/16 13:23] – [Managing citations and bibliographies] fix and expand related items zuphilip | ||
---|---|---|---|
Line 200: | Line 200: | ||
var itemids = collection.getChildItems(true); | var itemids = collection.getChildItems(true); | ||
</ | </ | ||
+ | |||
+ | === Create a New Collection in a function === | ||
+ | |||
+ | <code javascript> | ||
+ | async function createCollection(name) { | ||
+ | var currentCollection = ZoteroPane.getSelectedCollection(); | ||
+ | var collection = new Zotero.Collection(); | ||
+ | collection.name = name; | ||
+ | collection.parentID = currentCollection.id; | ||
+ | var collectionID = await collection.saveTx(); | ||
+ | return collectionID; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This function creates a new collection with a given name and makes | ||
+ | it a subcollection of the currently selected one. Since the saving | ||
+ | will result in a Promise object, we add the '' | ||
+ | function call and make sure that this is within an '' | ||
==== Zotero Search Basics ==== | ==== Zotero Search Basics ==== | ||
Line 323: | Line 341: | ||
the Zotero database. | the Zotero database. | ||
- | <code javascript> | + | <code javascript> |
+ | |||
+ | ==== Set two items as related to each other ==== | ||
+ | |||
+ | Given two items '' | ||
+ | to each other by using the '' | ||
+ | |||
+ | <code javascript> | ||
+ | await itemA.saveTx(); | ||
+ | itemB.addRelatedItem(itemA); | ||
+ | await itemB.saveTx(); | ||
- | This returns a list of items just like in the search examples. | ||
==== Get an Item's Attachments === | ==== Get an Item's Attachments === |