This project has moved and is read-only. For the latest updates, please go here.

Dynamic build CAMLQuery (several AND/EQ's)

May 23, 2011 at 10:38 AM


I am in a scenario where I need to build my CAMLQuery dynamically. Have any of you tried this before? I'm rather new to CAML and find it strange. What I want to do is to build several AND/EQ statements like SQL:

SELECT * from SPList WHERE LinkTitle = 1 AND LinkTitle = 3 AND LinkTitle = 7 AND ...

I want to pass in the values for the AND statements as an array, so obviously I have to do a loop to build my CAML. But how do I handle the strange way of nesting the AND's and EQUALS?

Code samples are much appreciated!

Thanks in advance!

May 23, 2011 at 2:40 PM
There are quite a few places in SPServices where I build up the CAMLQuery dynamically. An example is in the function cascadeDropdown. I'd suggest that you take a look there and post back with any questions.