Dynamic CAML Queries with current list item field value in where clause

Aug 25, 2009 at 2:43 PM



Thanks for your esteemed contribution to the commuity.


Can you plese clarify if I can use the following type of query in the caml query for filtering the lookup list?

<Query><Where><Eq><FieldRef Name="Proposal" /><Value Type="Lookup">[CURRENT LIST ITEM FIELD VALUE]</Value></Eq></Where></Query>


IS IT possible to use current list item field value in the caml query at all?


i couldnt figure it out, and my query returns 0 results when i tried with current ilist filed name surrounded by square brackets.


also, could this type of field be given default value by filter-querying a look up list ?


thanks a lot,


Aug 31, 2009 at 4:08 PM

I'd also like to know if this is possible.


Sep 1, 2009 at 8:42 AM


i need exactly the same!

Did you figure out any way to do this?


Sep 1, 2009 at 8:47 AM

no mate.. i havent..

 i have run into a wall on this.


btw, could any of u send me a sharepoint effort estimation (one from a past project of urs) and also a guide?.


i am looking for estimations on planning taxonomy(sites and doc-libraries with metadata)

custom webpart developments

Sep 1, 2009 at 8:48 AM

 my email id is venkata.subramani@asia.xchanging.com

Sep 1, 2009 at 2:08 PM

Have never used dynamic CAML queries before. For the filtered look-up, can the query reference value of previous column on the same form? The first column is a single look up called "Type of complaints", next column  is multiselect filltered look-up called "Complaints". Can the query for filtered look-up be something like :

Select <complaints> from <list> where <Type of Complaints> = <value selected on the form>

Is that possible?


Sep 7, 2009 at 2:41 PM

I'm looking for exactly the same.

Does anybody knows it?

Sep 9, 2009 at 6:20 AM


I'm not too sure I understand the question correctly but it appears to me that what you need actually do need is a cascaded filtered lookup field. The cascaded filtered lookup field can apply filters to the current listItem based on the value of another field within the same listItem.


The filtered lookup field isn't designed to work in cascaded mode. I'm currently working on the cascaded filtered lookup field but with no timelines due to other pressing business engagements.




Sep 10, 2009 at 5:18 PM
Edited Sep 10, 2009 at 6:02 PM

I'm not sure what you need either, but I can tell you that the CAML you included is missing a key attribute in the FieldRef tag. You should have either a LookupID or LookupValue attribute in that tag, LookupID if you are passing the ID of the lookup field or LookupValue if you are passing the text of the lookup field. Also, if you're using a web part parameter to filter on, it would be in the format of {$paramname} in stead of the suqare brackets you have.

<Query><Where><Eq><FieldRef Name="Proposal" LookupID="TRUE" /><Value Type="Lookup">{$paramname}</Value></Eq></Where></Query>

A couple of useful links, the first a CAML link and the second one a method to filter a dropdown list in SharePoint that I contributed to: