Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a "choice" (Checkboxes (allow multiple selections) ) column and wanted to convert the column as "managed metadata" column without any data loss. Suggest.

share|improve this question

2 Answers 2

From my experience this will have to be done programmatically. Add a new managed metadata column manually then write a console app or PowerShell to loop trhough the items/documents and match the selected value with the managed metadata equivalent. Then do a SystemUpdate(false) on the item (the false part will preventing the version from being increased)

Hope this helps

share|improve this answer
    
Is there any script readily available? –  Karthikeyan Dec 20 '12 at 5:38
up vote 0 down vote accepted

Updating the managed metadata Field -> Multivalue (allow multivalue)

○ Create a local term group, set, terms, term
○ Ref - http://social.msdn.microsoft.com/Forums/hu/sharepointdevelopmentprevious/thread/75ae3a89-7d28-41d9-b58c-56d4f7e9771d

$site = Get-SPSite "SiteURL"
$session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
$web = $site.openWeb() ;
$termStore = $session.TermStores["Enterprise Metadata Service Proxy"];
$group = $termStore.Groups["GroupName"];
$termSet = $group.TermSets["TermSet"];
$terms = $termSet.Terms;

$list = $web.Lists["ListName"];

$list.Items |% {

$spItem = $_;

write-host "Updating the Item - $($_.Id)";

#Get the taxonomy field for the list item
$taxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$spItem.Fields["TaxField"]

#Create a term collection
$termCollection = new-object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection($taxField);

$termName = $spItem["ChoiceField"].ToString() -replace ";#",",";

foreach($indTerm in $termName.Split(","))
{   
    if($indTerm.Length -gt 0)
    {
    #Get each individual term.
    $term = $terms | where {$_.Name -eq $indTerm}

    #Creating a field value that represents one term
    $taxonomyFieldValue = new-object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue($taxField)
    $taxonomyFieldValue.TermGuid = $term.Id
    $taxonomyFieldValue.Label = $term.Name  

    #Add term to collection.
    $termCollection.Add($taxonomyFieldValue)
    }
}

#Adding the Term Collection to the column.  
$taxField.SetFieldValue($spItem, $termCollection);
$spItem.SystemUpdate();

}

$web.Close();
$site.Dispose();
share|improve this answer
    
I think you misinterpret the question. The OP wants to convert a SPChoiceField to a SPTaxonomyField, not change an existing TaxonomyField from simple to multiple valued –  Steve B Dec 20 '12 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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