Thursday, 28 September 2017

SPServices: How to fetch filtered SharePoint list items?


$(document).ready(getListItems);

function getListItems() {
 
    $().SPServices({
        //webURL: "https://domain/sites/site_collection/site",
        operation: "GetListItems",
        async: false,
        listName: "Test List",
        CAMLViewFields: "<ViewFields Properties='True' />",
        CAMLQuery: "<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>YourValueHere</Value></Eq></Where></Query>",
        completefunc: success_getListItems
    });
 
}

function success_getListItems(xData, status) {
$(xData.responseXML).SPFilterNode("z:row").each(function () {
                var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
                $("#tasksUL").append(liHtml);
            });
}

No comments:

Post a Comment