var displayName="gnco\mahsa";
var accountName=(displayName);
var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.w|"+accountName+"'";
//execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
async: false,
success: function (data) {
var obj = data.d.UserProfileProperties;
if (typeof(obj) != "undefiend"){
obj = obj.results
$.each(obj,function(key,value){
if (obj[key] == "PhoneWork"){
alert(obj[key].value );
}
});
}
},
error: function () {
//alert("Failed to get details");
}
});
/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=%27i:0%23.w|gnco\mahsa%27
///////////////////////////////
///////////////////////////
function gettingUserProfileByAccountName(accountName) {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='"+accountName+"'",
headers: {
"Accept": "application/json; odata=verbose"
},
async: false,
contentType: "application/json; odata=verbose",
success: function (data) {
var results;
if (data.d) {
results = data.d.UserProfileProperties.results;
for (i = 0; i < results.length; i++) {
if (results[i].Key == "WorkEmail") {
$('input[title="Requestor Email"]').val(results[i].Value);
}
if (results[i].Key == "WorkPhone") {
$('input[title="Requestor Phone"]').val(results[i].Value);
}
}
}
}
});
}