I'm having trouble getting the values of a Managed Metadata Field in a SharePoint List.

Basically, what I want to do is given a string (ex. "Category"), it will find all the list items that match that string. The field I am using is Managed Metadata.

What I'm currently doing is getting all List Items then doing the standard:

TaxonomyFieldValueCollection test = item["TaxonomyFieldName"] as TaxonomyFieldValueCollection;

However, I always get "value does not fall within the expected range" error.

Can anyone point out how to do it properly?

Thank you!

  • Can you please check how you are searching inside the taxonomy field values ? We use taxonomyfieldvalueCollection only in places where the field supports multiple values else you can use the taxonomyfieldValue.
    – Arvi
    Commented Apr 7, 2015 at 9:04
  • My understanding is...Search for value "Category" in the SharePoint list which is a managed metadata field ...
    – Arvi
    Commented Apr 7, 2015 at 9:06

2 Answers 2


Option 1: Since you are getting all the items in the list then the caml query would not be of any use now.

TaxonomyFieldValueCollection test = item["TaxonomyFieldName"] asTaxonomyFieldValueCollection;

Now loop in the test collection variable to get all the taxonomy values present in the field.

foreach (var taxonomyValue in test) { if(taxonomyValue.Label
=="Category") { //Item Found } }

By this way you can check the value you are looking for.

Option 2: The other option would be using Caml Query. To form a query on a managed metadata value. Check the below link Query on MM field


Taxonomy and User fields are treated like Lookup fields and fall under "List View Lookup Threshold". It's default value is 8 or 12 (after some CU) for SP2013. Mind that even though the limit is called "View Lookup Threshold" it applies to getting single item as well.

If you request more lookup fields (including created by, modified by, etc.) SharePoint simply won't return some of the values. The result is the error message you're describing when you try to access field value.

Either limit the number of fields you're requesting or increase the limit (Web application -> General Settings -> Resource Throttling for SP2013).

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.