Skip to content

Instantly share code, notes, and snippets.

@phette23
Created May 15, 2019 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/f79329a23f9e86f768310f5ea2e7faed to your computer and use it in GitHub Desktop.
Save phette23/f79329a23f9e86f768310f5ea2e7faed to your computer and use it in GitHub Desktop.
custom function for Google Sheets to return data from VAULT (openEQUELLA) search API
// custom function for Google Sheets
// usage: TRANSPOSE(VAULTSEARCH("Student, Name")) returns data from Supplemental Portfolio Review collection
function VAULTSEARCH(query) {
var token = '...', // oauth access token
opts = {
contentType: 'application/json',
headers: { 'X-Authorization': 'access_token=' + token }
},
data = UrlFetchApp.fetch('https://vault.cca.edu/api/search/?collections=3eaf9745-e7d4-4cf6-be07-44691daa4714&order=modified&info=metadata,detail&q=' + encodeURIComponent(query), opts),
results = JSON.parse(data).results,
item = results[0],
major_re = /<major>(.*)<\/major>/,
cca_id_re= /<ccaAffiliated>(.*)<\/ccaAffiliated>/;
if (item) {
major = item.metadata.match(major_re) && item.metadata.match(major_re)[1]
cca_id = item.metadata.match(cca_id_re) && item.metadata.match(cca_id_re)[1]
return [item.owner.id, cca_id, major, item.modifiedDate, item.links.view]
}
return ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment