How To Import Managed Metadata Into SharePoint

Managed metadata is a hierarchical collection of centrally managed terms that you can define, and then use as attributes for items in SharePoint Server 2013.

You can use the Term Store Management Tool to create terms in a term set, or manage a term, such as copy it or move it. If you have many terms that you want to add, it will be more practical to import all the terms in the term-set instead of adding the terms individually. For information about how to import a large volume of terms presents in comma separated value (.csv) file, please follow the below-mentioned steps.

To create and manage terms in the Term Store Management Tool, you must be a Contributor, a Group Manager, or a Term Store Administrator.

So, please ensure you have followed all the following steps one-by-one to properly upload the large term sets present in comma-separated values (.csv file) into the SharePoint Central Administration. However, a small mistake can mess everything up.

Presented below are the two ways of uploading a large .csv file into the Central Administration.

The first one is using the PowerShell script.

  1. $ver = $host | select version  
  2. if ($Ver.version.major - gt 1) {  
  3.     $Host.Runspace.ThreadOptions = "ReuseThread"  
  4. }  
  5. if (!(Get - PSSnapin Microsoft.SharePoint.PowerShell - ea 0)) {  
  6.     Write - Progress - Activity "Loading Modules" - Status "Loading Microsoft.SharePoint.PowerShell"  
  7.     Add - PSSnapin Microsoft.SharePoint.PowerShell  
  8. }  
  9. $siteUrl = Read - Host "SiteUrl"  
  10. $filepath = Read - Host "File Path"  
  11. $usedForNavigation = $false  
  12. $groupName = Read - Host "Group Name"  
  13. $termsetname = Read - Host "Term Set Name"  
  14. ##Site URL  
  15. $site = Get - SPSite $siteUrl  
  16. ## CSV file  
  17. $file = get - item $filepath  
  18. $filename = $file.FullName  
  19. $session = Get - SPTaxonomySession - Site $site.Url  
  20. write - host $site.Url  
  21. $store = $session.DefaultKeywordsTermStore  
  22. #### Checking the Group name,  
  23.     if not present and getting the Site collection group  
  24. if ($groupName - eq "") {  
  25.     $group = $store.GetSiteCollectionGroup($site)  
  26. else {  
  27.     $group = $store.Groups[$groupName]  
  28. }  
  29. if ($group - eq $null) {  
  30.     write - host "Group not found" - ForegroundColor Red  
  31.     return  
  32. }  
  33. ##Getting the Termset  
  34. $termset = $group.TermSets[$termsetname]  
  35. if ($termset - eq $null) {  
  36.     ##Getting Import manager  
  37.     for the Term Store  
  38.     $manager = $store.GetImportmanager()  
  39.     $reader = new - object System.IO.StreamReader($filename)  
  40.     $alltermsadded = $false  
  41.     $errormessage = ""  
  42.     write - host "Importing $filename"  
  43.     $manager.ImportTermSet($group, $reader, [ref] $alltermsadded, [ref] $errormessage)  
  44.     $reader.Dispose()  
  45.     $termset = $group.TermSets[$termsetname]  
  46.     ## Checking if Site Navigation is enabled for the Term store  
  47.     ## One can add more custiom properties below depending upon the need  
  48.     if ($usedForNavigation - eq $true) {  
  49.         $termset.SetCustomProperty("_Sys_Nav_IsNavigationTermSet""True")  
  50.         $termset.SetCustomProperty("_Sys_Nav_AttachedWeb_SiteId", $site.ID.ToString())  
  51.         $termset.SetCustomProperty("_Sys_Nav_AttachedWeb_WebId", $site.RootWeb.ID.ToString())  
  52.         $termset.SetCustomProperty("_Sys_Nav_AttachedWeb_OriginalUrl", $site.RootWeb.Url)  
  53.     }  
  54.     if ([string]::IsNullOrEmpty($errormessage) - eq $false) {  
  55.         write - host $errormessage  
  56.     }  
  57. }  
  58. $store.CommitAll()  
  59. $site.Dispose()  
  60. sleep 20  
The second one is by using the Import functionality of Managed Metadata service present in Central Administration. Here are the steps.
  1. Go to the Central Admin.
  2. Under “Service Applications”, click “Manage Service Applications”.

    How To Import Managed Metadata Into SharePoint

  3. Select “Managed Metadata Service”, then click on “Manage” from a ribbon.

    How To Import Managed Metadata Into SharePoint

  4. Now, you can download a sample template of managed metadata structure by clicking on “View a sample import file”.

    How To Import Managed Metadata Into SharePoint

  5. Please add all your term details in this comma-separated value (.csv) file. 

    How To Import Managed Metadata Into SharePoint

  6. Once the (.csv) file is ready, then again, go to the Managed metadata page (as in step 4).
  7. Click on “New Group” from the context menu of “Managed Metadata”.

    How To Import Managed Metadata Into SharePoint

  8. Please provide a group name (here, I have provided “Organisation”).

    How To Import Managed Metadata Into SharePoint

  9. Now, click on “Import Term Set” and browse the file to import back to SharePoint. Now click on the “Ok” button after browsing the .csv file.

    How To Import Managed Metadata Into SharePoint

  10. Please wait while it is uploading the terms, once complete you can find all your term sets under the group “Organisation”.

    How To Import Managed Metadata Into SharePoint 
Hope this information will be helpful to you.