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

Return message when item not found - GetListItems

Jan 4, 2011 at 9:54 PM
After successfully completing the GetListItems function, I can inspect the response using alert(xDatat.responseText);
How can I capture when a list item is not found, or the function encountered an error?   
    operation: "GetListItems",
    async: false,
    listName: "PersonnelStatus",
    CAMLViewFields: "<ViewFields>" + 
    				"<FieldRef Name='PersonnelID' />" +
    				"<FieldRef Name='Status' />" +
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='PersonnelID'/><Value Type='Text'>" + empID + "</Value></Eq></Where><OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy></Query>",
    CAMLRowLimit: 1,
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("[nodeName=z:row]").each(function() {
        var empStatus = $(this).attr("ows_Status");
	if(empStatus == "In")
	  //Show the Start Button
	  //Show the End Button

Jan 4, 2011 at 10:32 PM
Jason: Even if there's an error, you should get an XML response (unless the server never responds). You can parse out the XML in a similar way, testing for the various error conditions. Unfortunately, the SDK gives us very little to go on with respect to errors. You sort of have to trigger them to see what happens. You can see how I do some of this in SPServices if you look at places where I've implemented the debug mode. M.
Jan 4, 2011 at 11:00 PM

I was thinking there had to be a way. Right now I'm passing in the query parameter via a textbox, and if the textbox is empty or if the values doesn't match a list item, nothing happens. I can handle the empty textbox with form validation, will the GetListItems return a value if there is no match? I'm going to take a look at your examples this evening, can they be found on your blog?




Jan 4, 2011 at 11:05 PM
Look at the SPServices functions where there's a debug option. That'll give you the best examples. M.