0

I need to export my Term Store taxonomy - the different term sets.

I see some people doing this with powershell but I only use the front end SP 2016 Enterprise screens.

Surely there must be a way to export this to excel from the screens. Do you know how to export the term store data?

0

Yes, i think you can do it using Script editor webpart. But you need to have access to to Term Store Management in Site Settings

1. Copy the following code to Script webpart in your page

<label for="termStoreId">Term Store ID</label>
<input id="termStoreId" type="text" style="width:250px;" placeholder="Enter your term store guid"/>
<label for="termSetId">Term Set ID</label>
<input id="termSetId" type="text" style="width:250px;" placeholder="Enter your term set guid"/>
<button type="button" onclick="getTerms();">Get terms</button>
<button type="button" onclick="clearTerms();">Clear</button>

<script>
function getTerms() {

    var context = SP.ClientContext.get_current();
    var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
    var termStores = taxSession.get_termStores();
    var termStore = termStores.getByName(document.getElementById("termStoreId").value);
    var termSet = termStore.getTermSet(document.getElementById("termSetId").value);
    var terms = termSet.getAllTerms();
    context.load(terms);
    context.load(termSet);
    context.executeQueryAsync(function () {
        var count = 0;
        var termEnumerator = terms.getEnumerator();
        var companies = '<table><tr><td><b>Terms</b></td></tr>';
        while (termEnumerator.moveNext()) {
            count++
            var currentTerm = termEnumerator.get_current();
            companies += '<tr><td>' + currentTerm.get_name() + '</td></tr>';
        }
        companies += '</table>';
        companies += '<br><span style="color:red">(' + count + ' terms found)</span>';
        document.getElementById("terms").innerHTML = companies;


    }, function (sender, args) {
        document.getElementById("terms").innerHTML = args.get_message();
        document.getElementById("terms").innerHTML = "<br><span style='color: green'>Ready to find terms!</span>";
    });

}
function clearTerms() {
        document.getElementById("terms").innerHTML = "<span style='color: green'>Ready to find terms!</span>";
        document.getElementById("termStoreId").value = "";
        document.getElementById("termSetId").value = "";
}

document.onreadystatechange = function () {
    if(document.readyState == "complete") {
        var spjs = document.createElement('script')
        spjs.setAttribute("type","text/javascript")
        spjs.setAttribute("src", "/_layouts/15/sp.js")

        var spruntimejs = document.createElement('script')
        spruntimejs.setAttribute("type","text/javascript")
        spruntimejs.setAttribute("src", "/_layouts/15/sp.runtime.js")

        var sptaxonomyjs = document.createElement('script')
        sptaxonomyjs.setAttribute("type","text/javascript")
        sptaxonomyjs.setAttribute("src", "/_layouts/15/sp.taxonomy.js")

        document.getElementById("terms").innerHTML = "<span style='color: green'>Ready to find terms!</span>";
    }   
}
</script>

<div id="terms"></div>

The above code is from https://github.com/kameronberget/SharePoint/blob/master/CSOM/GetTermsScriptPart.txt

2. Get the Term Store ID and Get Term Set ID

You can find this information in Site Settings. In Site Settings page, go to Term Store Management under Site Administration section. or the url normally like this http://contoso.com/_layouts/15/termstoremanager.aspx

Select root taxonomy(with home icon), then select general tab. This will get you information about Term Store ID

To get the TermSet ID, then select TermSet. In General tab, Grab the ID from the bottom of the General details page called Unique identifier.

3. Navigate back to your page which contain Script webpart In the field you should see term store id and term set id field. Copied the value from the step 2 above and click Get Terms button. Once you get the result you can copy to Excel spreadsheet

  • Suresh, thank you for this idea - it looks like it should work but it doesn't work for me. I can see that the fields are on my page and I enter both of the corresponding guids and press Get Terms but nothing happens - screen just sits there. Is there anything that needs to be turned on in order to run scripts? – jfitzy May 19 '17 at 20:25
  • Suresh, thank you for this idea - it looks like it should work but it doesn't work for me. I can see that the fields are on my page and I enter both of the corresponding guids and press Get Terms but nothing happens - screen just sits there. Is there anything that needs to be turned on in order to run scripts? Pls provide ideas on why it does not appear to execute when button is pressed. This is a new SP site so maybe something is not turned on? – jfitzy May 22 '17 at 20:23
  • Hi jfitzy, Btw i am not Suresh :). did you get it working? – Supermode May 22 '17 at 23:07
  • thanks Supermode - no I did not get it working - I decided to work on some other parts and then will come back to this later to try again. Do you have any other ideas on why the code works well enough to show the fields and buttons but then when button is pressed it does not seem to execute? Fitz – jfitzy May 30 '17 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.