I am working with a predefined set of Taxonomy data.

When I create a list item, I'm doing this based on a certain content type. I also want to apply taxonomy fields to this list item.

I'm using SP2010 clientContext object model.

Can someone post some sample code to demonstrate how it is possible to apply the taxonomy (meta data) field to the list item?


To ask another way, Do I apply the taxonomy field type to the list definition, the content type like any other field? Instead type would be "TaxonomyFieldType". Or do I manually add them on the fly to the list items as I go?

  • Does the list have the taxonomy column already there? Are you wanting to add this column to the list, or you asking about adding data into that column when adding a listitem?
    – James Love
    Commented Dec 15, 2010 at 10:51
  • @James, hi - I would like to include it at the content type level. I think I figured out 1/2 of the problem. It seems to be a type of siteColumn, so you can treat it as you would any other column once you have it setup in the content type right?
    – user879
    Commented Dec 15, 2010 at 16:33

2 Answers 2


This method uses object model (client context might work but untested)

using (SPSite spSite = new SPSite(this.siteURL))
  SPList oList = spSite.RootWeb.Lists[ListName]; 
  SPListItem oListItem = oList.AddItem();

 // Example of normal field 
 oListItem["Title"] = SomeStringTitle;

SPFieldCollection fields = spSite.RootWeb.Lists[oList.ID].Fields;
TaxonomyField fieldToSet = fields.GetFieldByInternalName(StringFieldName) as TaxonomyField ; 

Term term = // You should find the term as required in your function...

fieldToSet.SetFieldValue(oListItem, term);

// Don't forget to update

I use the SetFieldValue (which has some overloads) because you don't need to deal with hidden list this way, it gets the WssID for you (not sure how, but it works).

String fieldtype= getFieldTypeData(entityID, elementName);
FieldInformation fieldInfo = new FieldInformation();
fieldInfo.setDisplayName(IBSharePointUtils.replaceInternalSpecialChars(elementName + "_0"));



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.