SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm cross posting this from Stump the Panel for some more visibility from a wider developer base.

I'm trying to create a script I'll eventually adapt into a PreSaveAction, but I'm running into a stumbling block with my CAMLQuery. When I comment out the CAMLQuery, I return results back from the GetListItems call. When I apply my CAMLQuery I tested in U2U, nothing happens. Any pointers as to what my issue is?

var queryStringVals = $().SPServices.SPGetQueryString();
var cID = queryStringVals["c"];
//var cid = cID + ";#" + cID
var email = $().SPServices.SPGetCurrentUser({fieldName: "EMail",debug: false});
var ID = $().SPServices.SPGetCurrentUser({fieldName: "ID",debug: false});
//var string = ID + ";#" + email
    operation: "GetListItems",
    async: false,
    listName: "Current Registrations",
    CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='CourseID' /><Value Type='Lookup'>"+ cID +"</Value></Eq><Eq><FieldRef Name='EmployeeEmail' /><Value Type='User'>"+ email +"</Value></Eq></And><Where></Query>",
    completefunc: function (xData, Status) {
        //iC = $(xData.responseXML).find("[nodeName=rs:data]").attr("ItemCount");
share|improve this question
dont know about SPServices, but for "normal" SPQuery, you must not include the <Query>...</Query> tag around the where clause – Anders Rask May 10 '11 at 19:46
up vote 0 down vote accepted

Blast, typo in my CAMLQuery, that's why. I didn't close the <Where> element properly:

 CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='CourseID' /><Value Type='Lookup'>"+ cID +"</Value></Eq><Eq><FieldRef Name='EmployeeEmail' /><Value Type='User'>"+ email +"</Value></Eq></And></Where></Query>",
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.