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

Aug 25, 2009 at 1:43 PM

Hi,

 

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,

Venkat

Aug 31, 2009 at 3:08 PM

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

Thanks.

Sep 1, 2009 at 7:42 AM

Hi,

i need exactly the same!

Did you figure out any way to do this?

Regards

Sep 1, 2009 at 7: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 7:48 AM

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

Sep 1, 2009 at 1: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 1:41 PM

I'm looking for exactly the same.

Does anybody knows it?

Coordinator
Sep 9, 2009 at 5:20 AM

Hi,

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.

 

Regards,

Raphael.

Sep 10, 2009 at 4:18 PM
Edited Sep 10, 2009 at 5: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:

http://msdn.microsoft.com/en-us/library/ms462365.aspx

http://padavis.wordpress.com/2009/04/19/filtered-lookup-lists-in-sharepoint-2007-and-wss-30-%e2%80%93-using-javascript-and-keeping-attachments-working/