Logo 
Search:

Sharepoint 2010 Articles

Submit Article
Home » Articles » Sharepoint 2010 » Development and ProgrammingRSS Feeds

CAML Query with Managed Metadata

Posted By: Vladi Gubler     Category: Sharepoint 2010     Views: 308551

How to use Managed Metadata column in CAML queries

Hi,

We recently needed to add suppot for Managed Metadata column in out List Search product. Managed metadata column is of type TaxonomyFieldType, which in turns derives from the Lookup column type. List Search in its Advanced mode provides an interactive search query builder. You can enter up to 5 conditions, selecting a column for the condition will filter the list of possible operators and also present a suitable value selector, e.g. a date picker for a date or a combo box for lookups/choice fields.

Originally developed for 2007, List Search had no specific support for managed metadata. In fact, it treated it as a lookup field (because of the inheritance), which basically broke it completely.

When we got the request to support managed metadata field type, we started checking the possibilities. First we investigated the option of treating it as a lookup field. But apparently that would have required us to retrieve the IDs using SharePoint Server 2010-specific object model, introducing a lot of complexity (as we still need to support 2007 as well).

But the solution was actually extremely simple. Just use the field as you would any lookup, basing your query on the display value, not the ID. SharePoint will support any types of queries you can on a text field, such as equals, contains or begins with. So you can even enter just a couple of characters and receive search results!

Something like this works great:

<Where>
<Contains>
<FieldRef Name="ManagedMetadata"/>
<Value Type="TaxonomyFieldType">My Value</Value>
</Contains>
</Where>

So thanks to Microsoft for making it so easy for us!

Originally published at: http://www.infowisesolutions.com/blog/Comments.aspx?ArticleId=67

Share: 


Didn't find what you were looking for? Find more on CAML Query with Managed Metadata Or get search suggestion and latest updates.

Vladi Gubler
Vladi Gubler author of CAML Query with Managed Metadata is from Canada. Vladi Gubler says

CTO at Infowise Knowledge SolutionSpecializing in SharePoint development and retail, custom projects and consulting http://www.infowisesolutions.com

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!