What is the proper CAML structure for a Query String variable?

Mar 11, 2012 at 8:46 PM
Edited Mar 11, 2012 at 8:47 PM

SPFilterDropdown is cool. Thank you.

 

I'm attempting to apply it to a New Item DVWP - a multi-select lookup field - filtered by a Query String.

 

My first attempt:

CAMLQuery: "<eq><FieldRef Name='MyVariable'/><Value Type='Lookup'>{url:MyVariable}</Value></eq>",

 

And that about exhausts what I've been able to find on using query strings in CAML. Do I need to think outside the string and define the variable elsewhere?

is a pretty neat script. Thank you. 
Coordinator
Mar 12, 2012 at 2:34 AM

You can use $().SPServices.SPGetQueryString to get values from the Query String. Then you'll use the value(s) to build up your CAML.

var queryStringVals = $().SPServices.SPGetQueryString();
var thisID = queryStringVals["ID"];
query = "<Eq><FieldRef Name='MyVariable'/><Value Type='Lookup'>" + thisID + "</Value></Eq>";

Note that capitalization matters, e.g., EQ vs eq.

M.

Mar 12, 2012 at 12:24 PM
Edited Mar 12, 2012 at 12:24 PM

Thank you.

That's annoyingly simple and effective.

Coordinator
Mar 12, 2012 at 2:40 PM

Simple and effective are two of my goals. ;+)

M.