spfx Global Term Store without using get
-
07-02-2021 - |
Question
Just wondering whats the best way to get the name of the Global Term store without hard coding it?
I have this at the moment
var termStoreName = "Taxonomy_xxxxxxxxxxxxxxxxx";
const store: ITermStore = await taxonomy.termStores.getByName(termStoreName);
Solution
You can get it as below in SP Online:
1) Add the below import statement:
import { taxonomy, ITermStoreData} from "@pnp/sp-taxonomy";
2) After that you can get the name of the termstore as below:
taxonomy.termStores.get().then((d: ITermStoreData[]) => {
if(d.length > 0){
var termStoreName = d[0].Name;
console.log(termStoreName);
}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange