Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
$().SPServices({
    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");
   alert(xData.responseXML.xml);
     }
   }); 
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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.