Email: info@zenconix.com

Gets a username from SharePoint’s User profile service

Published on: 03/27/15 12:49 PM

Category:Javascript SharePoint 2013 Tags: , ,

Here is script of “How to get username from user id from Active directory”

 

[code language=”css”]
// get user name from id
function getUserFromId(userid) {
// var userid = _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = {
"accept": "application/json;odata=verbose"
};
$.ajax({
url: requestUri,
async: false,
contentType: "application/json;odata=verbose",
headers: requestHeaders,
success: onSuccess,
error: onError
});
function onSuccess(data, request) {
var Logg = data.d;
userLoginName = Logg.Title;
}
function onError(error) {
alert("error");
}
return userLoginName;
}
[/code]


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Get the User ID of Active Directory name in SharePoint by Javascript

How to get User Id from Site User if you have User’s active directory name [code language=”css”] //Get the id of user from AD name. function getADNameId(adName) { var UserData; $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteUsers?$Select=Id,Title&$filter=Title eq ‘" + adName + "’", type: "GET", async: false, headers: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose" }, success: function (data) { […]

Get selected element Id from Task List

“Very BAD practices !!!”  Sometimes situation comes that you don’t have any other options but you have to work on it and get work done. If this situation comes then you are just searching for any possible solution (many times you know that it is wrong approch to do so…).  I have come across the situation, […]

This form can not be rendered.

I am working with Workflow in SharePoint 2013, I got unexpected error today while creating association form. Error was, Solution: After searching it on internet I got to know that “State Services” was not started. So I have started it from central admin .   And now forms are rendering