SPServices Getlistitems failing at completefunc:

Jul 4, 2014 at 12:24 AM
Hi,

So, I have made a CAML query with two Eq statements. But I'm receiving a SOAP error at the completefunc. Maybe I'm just looking at it too much, or I've got something out of place, but the error message seems very vague to me.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Cannot complete this action.

Please try again.</errorstring><errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x80004005</errorcode></detail></soap:Fault></soap:Body></soap:Envelope>
The code that I am running is:
<script type="text/javascript">

jQuery(document).ready(function($) {

    var catCatsID = getUrlParameterUno('cat');
    var catSubCatsID = getUrlParameterUno('subcat');
            
    getCategories(catCatsID,catSubCatsID);
});


function getCategories(catCatsID,catSubCatsID) {
     //query to retrieve all items
    var query = "<Query><OrderBy><FieldRef Name='Promoted'/><FieldRef Name='Title'/></OrderBy><Where><And><And><Eq><FieldRef Name='Categories_x003a_CatURL' LookupId='TRUE' /><Value Type='Lookup'>"+catCatsID+"</Value></Eq><Eq><FieldRef Name='Sub_x0020_Categories_x003a_Link_x0020_URL' LookupId='TRUE' /><Value Type='Lookup'>"+catSubCatsID+"</Value></Eq></And><IsNotNull><FieldRef Name='Categories1' /></IsNotNull></And></Where></Query>";
    var camlViewFields = "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Categories1' /><FieldRef Name='Sub_x0020_Categories0' /><FieldRef Name='LinkFilename' /><FieldRef Name='Categories_x003a_CatURL' /><FieldRef Name='Sub_x0020_Categories_x003a_Link_x0020_URL' /><FieldRef Name='Promoted'/></ViewFields>";
    var fullURL = window.location.href;
    var currURL = fullURL.split('?')[0];
    $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "Pages",
        CAMLViewFields: camlViewFields,
        CAMLQuery: query,
        completefunc: function(xData, Status) {
            console.log(xData.responseText);
            console.log(Status);
            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                console.log('1');
                var Title = $(this).attr("ows_Title");
                var Name = $(this).attr("ows_LinkFilename");
                var Cat = $(this).attr("ows_Categories1");
                var SubCat = $(this).attr("ows_Sub_x0020_Categories0");
                var Catclass = $(this).attr("ows_Categories_x003a_CatURL").split('#')[1];
                var SubCatclass = $(this).attr("ows_Sub_x0020_Categories_x003a_Link_x0020_URL").split('#')[1];
                var promotedReport = $(this).attr("ows_Promoted").split('-')[1];
                //create blocks
                $("#catReports").append("<div class='report-boxes "+promotedReport+"' cat='"+Catclass+"' subcat='"+SubCatclass+"'><a href='/teams/MBSBI/pages/"+Name+"?Source="+currURL+"?cat="+Catclass+"&subcat="+SubCatclass+"'><div class='reportTitle' style='float:left;'>"+Title+"</div></a><div class='reportFrame'><h2><a href='/teams/MBSBI/pages/"+Name+"?Source="+currURL+"?cat="+Catclass+"'>"+Title+"</a></h2><div class='frameHolder'></div><footer class='reportframefoot'></footer></div></div>");
                
                var timer;
                $(".report-boxes").mouseenter(function(){
                    var that = this;
                    timer = setTimeout(function(){
                        if ($(".frameHolder", that).html().length < 1) {
                            $(".frameHolder", that).html("<div class='frameHover'></div><iframe class='ms-srch-hover-siteViewer' src='https://microsoft.sharepoint.com/teams/MBSBI/Pages/"+Name+"' frameborder='0px' scrolling='no' style='border: 2px #dadada solid; width: 1200px; height: 900px; display: block; transform: scale(0.4075, 0.441111);'></iframe>");
                        }
                    }, 1000);
                }).mouseleave(function() {
                    clearTimeout(timer);
                });
                                    
            }); // end completefunc
        }
    }); // end SPServices call
    setActive();
}

function getUrlParameterUno(sParam) {
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}

</script>
Any help would be much appreciated. Mind you this works without the query variable. SO I feel like I must be writing my query incorrectly.
Coordinator
Jul 4, 2014 at 3:46 PM
Excited:

I don't see anything obviously wrong with your CAMLQuery. You might want to look at the POST in Firebug or Fiddler and see if it's constructed the way you think it should be. Maybe the IDs aren't getting there?

M.