-
-
Save maxali/8fc6a5a20cbc7cf787a62ff956d411ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Rest query example: | |
var url = _spPageContextInfo.siteServerRelativeUrl + "/_api/web/lists/getbytitle('ListName')/items?"; | |
url = url + "&$expand=TaxCatchAll,FHI_Responsible"; | |
url = url + "&$select=*,TaxCatchAll/Term,TaxCatchAll/IdForTerm,TaxCatchAll/Term1033,TaxCatchAll/Term1044"; | |
*/ | |
// usage | |
// getTaxonomyValue(listItem, field); | |
/** | |
* extracts Taxonomy field value from TaxCatchAll field. | |
* listItem includes $select=TaxCatchAll/Term,TaxCatchAll/IdForTerm,TaxCatchAll/Term1033,TaxCatchAll/Term1044 | |
* @returns {String} | |
* @param {ActivityList.Value} listItem SP ListItem in json;odata=nometadata format | |
* @param {String} field SP Field internal name | |
* | |
* @memberOf ActivityItems | |
*/ | |
function getTaxonomyValue(listItem, field) { | |
if (!listItem[field]) return; | |
var taxField: TaxField = listItem[field]; | |
var taxCatchAll = listItem.TaxCatchAll; | |
var taxFieldInfo = taxCatchAll.find(tax => tax.IdForTerm === taxField.TermGuid); | |
return taxFieldInfo['Term' + _spPageContextInfo.currentLanguage] || taxFieldInfo['Term'] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment