I'm using SharePoint 2010 and SPServices to retrieve the elements of a list, but no all items,
My list have these fields:
- Year: calculated column
- Month: Choice column
- Company: Line of text
- Department: Choice Column
- Type: Choice Column
- Cost: Line of text
I want to filter the list by Year, Month, Company, Department, and Type so this is the code:
$().SPServices({
operation: "GetListItems",
async: false,
listName: "{list guid}",
viewName: "{view guid}",
CAMLViewFields: "<ViewFields><FieldRef Name='Title'/><FieldRef Name='Cost' /></ViewFields>",
CAMLQuery:"<Query><Where><And><Eq><FieldRef Name='Year'/><Value Type='Integer'>2016</Value></Eq><Eq><FieldRef Name='Month' /><Value Type='Integer'>11</Value></Eq></And><And><Eq><FieldRef Name='Company' /><Value Type='Text'>CompanyName</Value></Eq><Eq><FieldRef Name='Department' /><Value Type='Text'>IT</Value></Eq></And><Eq><FieldRef Name='Type' /><Value Type='Text'>two</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var liHtml =$(this).attr("ows_Title");
var Cost =$(this).attr("ows_Cost");
});
}
});
My problem is that a can't retrieve anything and the next step with all the items retrieved o want to sum all there Cost values If you guys can help me I really appreciate