SharePoint 2013 get Person or Group field value(s) using REST API
Below Code snippet for fetching the Person or Group field value by using REST API.
$.ajax ({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Produccts')/items('"+ietmID+"')?$select=Title,Flag,Approver/Title&$expand=Approver",
type: "GET",
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method": null
},
cache: false,
success: function(data)
{
var listiteminfo = data.d;
var itemTitle=listiteminfo.Title;
var approvers="";
var approverResults=listiteminfo.Approver.results;
for (var j = 0; j < approverResults.length; j++)
{
approvers=approvers+';'+approverResults[j].Title
}
},
error: function(data)
{
alert("error");
//$("#ResultDiv").empty().text(data.responseJSON.error);
}
});
$.ajax ({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Produccts')/items('"+ietmID+"')?$select=Title,Flag,Approver/Title&$expand=Approver",
type: "GET",
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTP-Method": null
},
cache: false,
success: function(data)
{
var listiteminfo = data.d;
var itemTitle=listiteminfo.Title;
var approvers="";
var approverResults=listiteminfo.Approver.results;
for (var j = 0; j < approverResults.length; j++)
{
approvers=approvers+';'+approverResults[j].Title
}
},
error: function(data)
{
alert("error");
//$("#ResultDiv").empty().text(data.responseJSON.error);
}
});
Comments
Post a Comment