I'm copying documents between document libraries in different site collections. I have saved my source library template, uploaded to destination site collection and created library based on that template. Library has managed metadata field.

After copying file from source to destination library, I found out that my managed metadata field is not copied well. When I'm in the main view of destination library, I can't see managed metadata field values. But when I go to item edit mode, I can see proper value of that field. What is more interesting, when I upload document manually to destination library, choose metadata and save item - I can't see this field value too!

After some debugging I found out that my field after copying between libraries (called Subject) is set as follows:

Subject = |06c40660-e8e8-4580-a611-0d5c66999730
Subject_0 = Biologia|06c40660-e8e8-4580-a611-0d5c66999730

but Taxonomy Catch All Column is empty...

I'm using this code for copying and setting metadata:

using (SPSite sourceSite = new SPSite(currentSiteUrl))
                    using (SPWeb sourceWeb = sourceSite.OpenWeb())
                        SPList sourceList = sourceWeb.Lists["Dokumenty"];
                        SPListItem sourceItem = sourceList.GetItemById(Int32.Parse(itemId));
                        SPFile sourceFile = sourceItem.File;
                        using (SPSite destSite = new SPSite(destinationSiteUrl))
                            using (SPWeb destWeb = destSite.OpenWeb())
                                destWeb.AllowUnsafeUpdates = true;
                                SPList destList = destWeb.Lists["Destination library name"];
                                SPFolder destFolder = destList.RootFolder;
                                SPFile destFile = destFolder.Files.Add(sourceFile.Name, sourceFile.OpenBinary(), true);

                                SPListItem destItem = destFile.Item;

                                // source taxonomy fields
                                TaxonomyFieldValue taxSourceSubject = (sourceItem["Subject"] as TaxonomyFieldValue);
                                TaxonomyField taxTargetFieldSubject = (TaxonomyField)destItem.Fields.GetFieldByInternalName("Subject");    
                                TaxonomySession taxonomySession = new TaxonomySession(destSite);
                                TermStore termStore = taxonomySession.TermStores[taxTargetFieldSubject.SspId];

                                var termSubjectSet = termStore.GetTermSet(taxTargetFieldSubject.TermSetId);
                                var termSubject = termSubjectSet.GetTerm(new Guid(taxSourceSubject.TermGuid));


                                destItem["Title"] = sourceItem["Title"];

                                string fields = "";
                                foreach (SPField f in destItem.Fields)
                                    fields += "<br/>" + f.Title + " = " + destItem[f.Title];
                                StatusLabel.Text += "<br/><br/>" + fields;
                                destWeb.AllowUnsafeUpdates = false;

Maybe my destination library is missing something?

  • Are you using a custom or default WebTemplate/Site Definition? If default - which one? Dec 1, 2011 at 11:57
  • Source site collection is based on Document Store template and destination site collection is based on modified template of team site.
    – jjczopek
    Dec 1, 2011 at 12:46

1 Answer 1


As it showed out, the problem was that managed metadata fields in destination library come from template. After deleting metadata columns from library, and adding them back by hand (with the same name) solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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