Retrieve column values from a list using JQuery and Web Services

Retrieve column values from a list using JQuery and Web Services


How to write a Javascript web service / function to retrieve column values from a field, with a date filter condition.


Following is the Javascript code (function) to retrieve the column values from a list using web services.  The values used in this example reference a "Team Member" field from a "User Allocation list" list with a date filter condition.

Script Code

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();
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");
return aTmp;

See Also

How to get table cell text with Javascript

Create HTML table out of object array in Javascript

Leave a Comment
  • Please add 2 and 5 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Page 2 of 2 (11 items) 12
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
  • Maheshkumar S Tiwari edited Original. Comment: Added tags

  • TNJMAN edited Revision 1. Comment: made a code block and tried to fix headers

  • TNJMAN edited Revision 2. Comment: more formatting

  • TNJMAN edited Revision 3. Comment: code block...

  • TNJMAN edited Revision 5. Comment: code block formatter not working.

  • TNJMAN edited Revision 6. Comment: sometimes this site is frustrating! inserted code block again - 3rd time is the charm.

  • TNJMAN edited Revision 7. Comment: broken editing -- arrghh!

  • TNJMAN edited Revision 8. Comment: i will keep trying

  • TNJMAN edited Revision 9. Comment: finally!

  • TNJMAN edited Revision 10. Comment: Spiff it up.

  • TNJMAN edited Revision 12. Comment: wiki editor still broken.

  • You know, what would be great is for you to "run this code" and then capture an image of the table - how the "Team Member" field and "User Allocation List" look - then you can include an image here, and it will be more fabulous.

Page 1 of 1 (12 items)