Monday, November 9, 2015

Get the user information from people picker column using REST call

If you want to get the user information from the people picker column using REST call follow this one

Note: Here we have  used the expand keyword  in REST call for two people picker columns in sharepoint list

var listName = "Leave-WFH Request";
var restQuery = "LeaveCategory eq 'Holiday' and  From gt '11/03/2015' and To lt '21/03/2015'";  
 
        jQuery.ajax({
            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/Items?$select=Title,From,To,EmployeePhone,LeaveCategory,EmployeeLocation,EmployeeName/Title,Manager/Title&$expand=EmployeeName,Manager&$filter="+ restQuery,
            type: "GET",
            headers: { Accept: "application/json;odata=verbose" },
            success: function (data) {
}
error: function (jqXHR, textStatus, errorThrown) {
                Console.log("UpcomingEventsHomePage.js:loadEventsData:: " + textStatus);
            }
        });

If we have single column the query will be

    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/Items?$select=Title,From,To,EmployeePhone,LeaveCategory,EmployeeLocation,EmployeeName/Title&$expand=EmployeeName&$filter="+ restQuery,

No comments:

Post a Comment