I recently had a requirement to export a list of terms in a specific term set within Office 365. Unlike On Premises, we cannot use PowerShell to get at our terms. I had to use CSOM (Client Side Object Model) to get at the Taxonomy store and then fetch the terms. After getting this to work I decided to make it a bit more reusable. Let’s get at it…
To make this work you must first add a Script Editor web part to your page:
After you copy the code into the editor the preview should update as shown below.
Note: This code is using lazy asynchronous loading methods for loading the sp.js, sp.runtime.js and sp.taxonomy.js that are required for these functions. This is so you don’t have to load them into the master page. However, if you choose to load them into the master page reference this blog post for the proper way to do so.
Click Insert and Save the Page.
Sweet! Now we have the code ready to go and the status tells us we are ready to fetch some terms. (The Ready to find terms also means that the DOM is fully loaded and our JS files have been loaded behind the scenes.
In order to get terms you must first enter the Taxonomy Store ID and a Term Set ID. The Taxonomy store ID is effectively your tenants’ Managed Metadata Service. To get the Store ID simply open Term Store Management from any site collection OR login to the SPO (SharePoint Online) Admin Center.
From here you will see the root Taxonomy_blah will be your Store ID. Record this ID.
Next, click on the term set that you want to query. Grab the ID from the bottom of the General details page. (note the terms in the list to the left)
Plug both of these values into your web part and click get terms.
There you go! All of your terms that we saw in the above image of the term store are output to a table. From here you can copy and paste into Excel, etc. You can copy and paste some of these values within the browser itself but you get a lot of extra ‘junk’. This method provides a nice clean list:)
Latest posts by Beth Ingebretson (see all)
- Join Us For March MNSPUG — Wednesday March 8 - March 3, 2017
- Avtex SharePoint Expert Brian Caauwe to Host Sessions at InspireX 2017 - February 8, 2017
- Patient Experience Technologies - November 15, 2016