Fixing taxonomy terms after a Metalogix Migration Fixing taxonomy terms after a Metalogix Migration
Joel Plaut

Joel Plaut

July 29, 2014

All Post
img
Share:

When migrating from SharePoint 2010 to 2013 using the Metalogix Content Matrix 7.0.0.1 migration tool, a taxonomy issue was encountered. The individual term from the SP2010 source was not applied to the SP2013 destination and associated with the correct term set and term.

The destination taxonomy field appeared empty in every sense. It was not displayed when viewing the Item, nor in the list view.

However one remnant of the term did appear in a surprising place. Within the read-only property bag of the item (item.XML) there was a field with what appears to be a GUID devoid of dashes as property name, with a value that seems somewhat usable.

Additional Read

How to Choose the Right SharePoint Migration Tool and Service Partner?

The property value in this case was “a466a2acd62b498291c78829c2bb5fe3”.
item.GetFormattedValue(“a466a2acd62b498291c78829c2bb5fe3”) gets the value, as does item[“a466a2acd62b498291c78829c2bb5fe3”]
This is the GUID of the target field associated with the termset.
To make this more generic, I set the targetField to the field name we are looking for, and derive the GUID generically this way.

[Microsoft.SharePoint.Taxonomy.TaxonomyField]$taxonomyField = $item.Fields.GetField($targetField)

Then stripped off the dashes, to get it into the format that appears in the property bag:

$FieldGUID = $taxonomyField.id.Guid.tostring().replace("-","")

Then I derive the value for the property:

$FQterm = $item[$fieldGUID]

The value appears in the internal format, so I strip off any text appearing after a pipe:

$fqTerm = $FQterm.Substring(0,$FQterm.IndexOf("|"))

To match to the appropriate term, we need to handle the situation where a text value can appear under multiple parents. So we walk the hierarchy to find the single correct match. First we split the term into colon delimited segments:

$termHierarchy = $FQterm.Split(":")

Then check parent term matching to narrow to one appropriate matching term. This assumes checking two levels finds the match. It can be extended to match 7 levels deep if needed:

if ( $TC.count -gt 1)
{
  $termIdx=-1;
  if ($termHierarchy.count -ge 2)
  {
     $ParentTerm = $termHierarchy[$termHierarchy.count-2];
  }
  else
  {
    $ParentTerm = $null;
  }
 
  for ($ti=0; $ti -lt $TC.count; $ti++) #loop to ensure parent is right one
  {
     if ($TC[$ti].parent.getdefaultlabel(1033) -eq $parentTerm)
     {
       $termIdx = $ti;
     }
  }
}

Start Your SharePoint Online Migration Project In A Click

Our technology and wide delivery footprint have created billions of dollars in value for clients globally and are widely recognized by industry professionals and analysts.

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to talk?

Drop us a line. We are here to answer your questions 24*7.