function GetUserIdByName(name) {
var userId = "";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteUsers?$Select=Id,Title&$filter=Title eq '" + name + "'",
type: "GET",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data) {
userId = data.d.results[0].Id;
},
error: function(err) {
console.log(JSON.stringify(err));
}
});
return userId;
}
var userId = "";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteUsers?$Select=Id,Title&$filter=Title eq '" + name + "'",
type: "GET",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function(data) {
userId = data.d.results[0].Id;
},
error: function(err) {
console.log(JSON.stringify(err));
}
});
return userId;
}
No comments:
Post a Comment