Get Login Name and Display Name by User ID using SharePoint 2013 REST API
We can pass the user id to the below function & we can get the user name.
function getUser(id){
var returnValue;
jQuery.ajax({
url: "http://YourSite/_api/Web/GetUserById(" + id + ")",
type: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function(data) {
var dataResults = data.d;
//get login name
var loginName = dataResults.LoginName.split('|')[1];
alert(loginName);
//get display name
alert(dataResults.Title);
}
});
}
Please refer this link for more details Link1
function getUser(id){
var returnValue;
jQuery.ajax({
url: "http://YourSite/_api/Web/GetUserById(" + id + ")",
type: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function(data) {
var dataResults = data.d;
//get login name
var loginName = dataResults.LoginName.split('|')[1];
alert(loginName);
//get display name
alert(dataResults.Title);
}
});
}
Please refer this link for more details Link1
Comments
Post a Comment