Get Logged In User Full Name



function getLoggedInUserFullName() {
var ODataPath = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc";
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("GET", ODataPath + "/SystemUserSet(guid'" + Xrm.Page.context.getUserId() + "')", false);
xmlHttpRequest.setRequestHeader("Accept", "application/json");
xmlHttpRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xmlHttpRequest.send();
if (xmlHttpRequest.status === 200) {
var user = JSON.parse(xmlHttpRequest.responseText).d;
return user.FullName;
}
else {
return "Error Occured!!";
}
}

function getLoggedInUserName() {
var ODataPath = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc";
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("GET", ODataPath + "/SystemUserSet(guid'" + Xrm.Page.context.getUserId() + "')", false);
xmlHttpRequest.setRequestHeader("Accept", "application/json");
xmlHttpRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xmlHttpRequest.send();
if (xmlHttpRequest.status === 200) {
var user = JSON.parse(xmlHttpRequest.responseText).d;
var domainName = user.DomainName;
return domainName.substring(0, domainName.indexOf("@"));
}
else {
return "Error Occured!!";
}
}

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in Ms Dynamics CRM 2013, MS Dynamics CRM 2015. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s