SharePoint Blog - René Hézser

Anmelden  RSS Feed RSS Feed
Startet die Suche

Archive

Kategorien

Links

Andere Blogs




ITaCS GmbH


SPQuery with lookup columns returns no data  

Jun 042009

An SPQuery for lookup columns should be easy. Start the famous U2U Caml Editor, configure your query, and query the list.

image

This query will get a result if the lookup column stores something like “1;#1”. But if its value is e.g. “1;#Title”, the query will not return an item.

So what can we do about it?

Add a LookupId='TRUE' to your query, so it will look like this:

   1:  <Where>
   2:     <Eq>
   3:        <FieldRef Name='LookupField' LookupId='TRUE'/>
   4:        <Value Type='Lookup'>2</Value>
   5:     </Eq>
   6:  </Where>

Remember to omit the Query tags from the U2U Caml Editor when pasting the query into your Visual Studio source code!

 
Posted by René Hézser | 1  Comment | Trackback Url  | 0  Links to this post | Bookmark this post with:        
Tags: Development, SharePoint, SPQuery
Technorati Tags: , ,

Links to this post

Comments

commented on  Thursday, March 04, 2010  6:01 PM  by  iFunky Application Development
I've been having probs with these damn Sharepoint queries, any benefits of doing SPContext.Current.Web.Lists["meetings"] instead?

Name *:
URL:
Email:
Kommentar:


CAPTCHA Image Validation