0

I have a Metadata like this

Demo --> Group
 OrgDemo --> Termset
  Demo1 --> Term
      A -->Level1
        A1-->Level2
        B1
        c2
           c21-->Level3
           c22
              c221-->Level4
              D223
     B
        B1
        B2
        B3
             B21
             B23

The Metadata is already there and the sorting is done by Sharepoint automatically. Now i want to write to Powershell to read from the XMl file and apply the customsort order for example in the XMl file the sort order is like this B1, A1.

I have already started writing the powershell script. I have applied the customsorder for level1 and if there is more levels how to do it any idea ?

0

You need to read the term's in each level - then set the sort order for those - commit changes and move to the next level - do the same

Example -

$taxonomySession = Get-SPTaxonomySession -Site "Your Site Path"
$termStore = $taxonomySession.TermStores["Your Term Store Name"]
if($termStore -ne $null){                     
    $group = $termStore.Groups["Demo"]
    if($group -ne $null){                         
        $termSet = $group.TermSets["OrgDemo"]
        $subTermSet1 = $termSet["Demo1"]
        $aTerm = $subTermSet1["A"]
        $bTerm = $subTermSet1["B"]

        $customSortOrder = $aTerm.ID.ToString() + ":" + $bTerm.ID.ToString(); 
        $subTermSet1.CustomSortOrder = $customSortOrder 
    }
}
$termStore.CommitAll();

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.