Accessing SharePoint TermStore and playing with that is not a big deal in SPFx, we can do that with some tweaks. Since we don’t have direct REST API support for this service, we will be using the old JSOM method to add/edit TermStore in SharePoint Framework webpart.
Environment setup
We need to load some reference scripts to access SP.PageContext info. Please refer my article about reading SharePoint TermStore Managed Metadata In SharePoint Framework (SPFx) and follow the step by step guidelines in that to set up the environment to add/edit the TermSet.
What is Submission Policy in TermStore?
As we know, SPFx is functioning based on user context so the user can’t access anything out of his/her permission scope through SPFx app. TermStore is something related to SharePoint Admin Center, so then how do we add/edit TermStore through SPFx app?
We do have an option for that in TermStore settings as described below,
- Go to below URL to access TermStore settings in your tenant
https://tenantname-admin.sharepoint.com/_layouts/15/termstoremanager.aspx - Expand your TermGroup and select the TermSet, in my case I have selected People/Department
Create a Term in SPFx
Once you are finished with the environmental setup, the next step is to read the specific TermSets like department and location, so we can add the new term value in that.
Please follow the below code snippet to read the TermSet using spPageContext load and execute methods,
- let spContext: SP.ClientContext = new SP.ClientContext(siteColUrl);
- let taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(spContext);
- let termStore = taxSession.getDefaultSiteCollectionTermStore();
- let termGroups = termStore.get_groups();
- let termGroup = termGroups.getByName("People");
- let termSets = termGroup.get_termSets();
- let termSet = termSets.getByName("Location");
- let lcID= 1033; // Mention the lcid as per your requirement

Vishakha PatilPosted Nov 7, 2024, 10:44 AM
I am getting this error while fetching termset message: "Cannot access https://webshell.suite.office.com"
Rose AmeliePosted Mar 12, 2021, 9:59 AM
Hello Jayakumar Balasubramaniam, thank you for this article. Do you know how we can create a new Labels for a term like the pnp/Js method : term.createLabel("label text", 1031, true) using spfx ? ( the pnp/Js method does not work ). Thank you