Created
July 1, 2019 21:33
-
-
Save chrisobriensp/34e515cb36a77c1f5c18fb4735fe79e4 to your computer and use it in GitHub Desktop.
Revisions
-
chrisobriensp created this gist
Jul 1, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ // used to get object suitable for writing a single-valued taxonomy value to SharePoint from the PnP taxonomy picker control.. private static getTaxonomyTerm(termDetails: IPickerTerm): ITaxonomyTerm { let taxonomyTerm: ITaxonomyTerm; if (termDetails) { taxonomyTerm = { TermGuid: termDetails.key, Label: termDetails.name, WssId: -1 }; } return taxonomyTerm; } // used to get object suitable for setting current value of PnP taxonomy picker control from data fetched from SharePoint.. private static getPickerTerm(retrievedTaxValue: ITaxonomyTerm, taxCatchAll: Array<any>): IPickerTerm { let pickerTerm: IPickerTerm; if (retrievedTaxValue) { if (taxCatchAll && taxCatchAll.length > 0 && retrievedTaxValue) { const result = taxCatchAll.filter(item => item.ID === retrievedTaxValue.WssId); if (result.length === 1) { pickerTerm = { name: result[0].Term, path: result[0].Term, key: retrievedTaxValue.TermGuid, termSet: undefined, termSetName: undefined }; } else { console.warn("setTaxonomyTerm: WARNING! Unable to load value for field: " + retrievedTaxValue.Label); console.warn({ taxCatchAll }); } } } return pickerTerm; }