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

Mar 11, 2012 at 7:46 PM
Edited Mar 11, 2012 at 7: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. 
Mar 12, 2012 at 1: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.


Mar 12, 2012 at 11:24 AM
Edited Mar 12, 2012 at 11:24 AM

Thank you.

That's annoyingly simple and effective.

Mar 12, 2012 at 1:40 PM

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