1

I'm trying to get a list count based on the CAML query below, but it keeps returning zero. It should return the number of projects assigned to a designer (person or group type column) which their project status is NOT complete. Any ideas what might have wrong in my code.

Here are some excerpts of my code:

<!-- SPSERVICE QUERY BLOCK-->
<script>
$(document).ready(function(){
    $(".showResultsOpenProjs").click(function(){
        var selectedDesignerOpenProjs = $("#selectedDesignerOpenProjs").val(); alert(selectedDesignerOpenProjs);

        $().SPServices({

operation: "GetListItems",
async: false,
listName: "Marketing Requests",
CAMLRowLimit: 5000,
CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='Assign_x0020_To'/><Value Type='User' >" + selectedDesignerOpenProjs + "</Value></Eq><And><Neq><FieldRef Name='Status'/><Value Type='Text' >COMPLETED</Value></Neq><Neq><FieldRef Name='Status'/><Value Type='Text' >CANCELLED</Value></Neq></And></And></Where></Query>",


            completefunc: function(xData, Status)
            {
                var dataLengthOpenProjs = $(xData.responseXML).SPFilterNode("z:row").length;
                $(".resultsDivOpenProjs").html("Designer: <b>" + selectedDesignerOpenProjs + " </b><br>Projects in this date range: <br><h1><b>" + dataLengthOpenProjs + "</b></h1>");
                $(".resultsDiv2").empty();

                $(xData.responseXML).SPFilterNode("z:row").each(function()
                {
                    var jobIDOpenProjs = parseInt($(this).attr("ows_ID"));
                    console.log($(this).attr("ows_Title"));

                    $(".resultsDiv2").append("Project Title: <b>" + jobIDOpenProjs + " - <a href='https://dschs.sharepoint.com/SchoolDevelopment/StudentOutreach/Lists/Marketing%20Requests/Item/displayifs.aspx?List=f13e5db4-080c-4be2-92e9-7df0b7cdd852&ID=" + jobIDOpenProjs + "' target='_blank'>"+$(this).attr("ows_Title")+"</a></b><br>");
                });



    /************Debugging********
        alert(Status);
        var out = $().SPServices.SPDebugXMLHttpResult({
        node: xData.responseXML
        });
        $("#debug").html("").append("<b>This is the output from the GetList operation:</b>" + out);
    /******************************/


            }
        });
    })
});         
</script>
23
  • Is your Assign To field a person type field? What's an example value for selectedDesignerOpenProjs?
    – Erin L
    Jul 14, 2016 at 18:46
  • Your <And> tags aren't nested properly, plus you have <And></And> towards the end of your query string that doesn't make any sense.
    – Erin L
    Jul 14, 2016 at 18:51
  • @ErinL yes. "Assign To" column is a Person/Group people picker column.
    – Ivan
    Jul 14, 2016 at 20:36
  • @ErinL I tried the CAML query you provided and still returns 0. I already have a view for this list displaying only NOT COMPLETE projects. I set the viewName to the name of this view, and still nothing. An example value you could use is "Jake White"
    – Ivan
    Jul 14, 2016 at 20:53
  • @ErinL when activating column totals, the count for "Jake White" comes to 23 open projects.
    – Ivan
    Jul 14, 2016 at 21:00

1 Answer 1

3
operation: "GetListItems",
async: false,
listName: "Marketing Requests",
viewName: "54E61A50-B5A9-4D59-91B9-EA9D280B8C24",
CAMLRowLimit: 5000,
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Assign_x0020_To'/><Value Type='User' >" + selectedDesignerOpenProjs + "</Value></Eq></Where></Query>",
completefunc: function(xData, Status){
        /************Debugging********/
            alert(Status);
            var out = $().SPServices.SPDebugXMLHttpResult({
            node: xData.responseXML
            });
            $("#debug").html("").append("<b>This is the output from the GetList operation:</b>" + out);
        /******************************/
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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