Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a problem with filtering list items using CALM

I Have this list: Code - Text, Name - Text, Link - Text, Order No - Number, Parent - Lookup to this List. I want to filter all items where Parent is not selected (i.e none)

Here is my CALM query but it's not giving the right solution:

string camlquery = String.Format(@"<where>
                                                <Eq><FieldRef Name='{0}' /><Value Type='Lookup'></Value></Eq>
                                                </where>
                                               <OrderBy>
                                                <FieldRef Name='Order No'></FieldRef>
                                                </OrderBy>
                                               ", this.MenuItemParentField);

MenuItemParentField it's the name of the lookup column MenuItemParentField="Parent"

What is going wrong with my calm query

Any help would be appreciated

Thank you

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use IsNull Element (Query) instead of Eq Element (Query)

string camlquery = String.Format(@"<where> 
                                     <IsNull><FieldRef Name='Parent' /></IsNull> 
                                   </where> 
                                   <OrderBy> 
                                     <FieldRef Name='Order No'></FieldRef> 
                                   </OrderBy> 
                                   ", this.MenuItemParentField); 
share|improve this answer
    
It's not working :( –  MIlena Jul 17 '12 at 13:33
    
What if you remove the OrderBy, thats not a right InternalName, sorry I didn't see that before –  Per Jakobsen Jul 17 '12 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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