Requirement: To get the values of "Team Member" field from "User Allocation list" list with a filter condition.
Solution:
Following is the javascript code to retrieve the column values from a list using web services.
function getCompletedEmployeesList(){
var date = new Date();
var aTmp = new Array();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
firstDay = firstDay.getFullYear()+"-"+(firstDay.getMonth()+1)+"-"+firstDay.getDate();
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
lastDay = lastDay.getFullYear()+"-"+(lastDay.getMonth()+1)+"-"+lastDay.getDate();
$().SPServices({
operation: "GetListItems",
async: false,
listName: "User Allocation List",
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: "<Query><Where><And><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq><And><Leq><FieldRef Name='Week_x002d_Ending' /><Value IncludeTimeValue='FALSE' Type='DateTime'>"+lastDay +"</Value></Leq><Geq><FieldRef Name='Week_x002d_Ending' /><Value IncludeTimeValue='FALSE' Type='DateTime'>"+firstDay +"</Value></Geq></And></And></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var teamMember = $(this).attr("ows_TeamMember");
aTmp.push(teamMember);
});
}
});
return aTmp;
}
No comments:
Post a Comment