We are currently using Dynamics CRM 2016. We have an iframe which will be used to load another application for the time being. We would like to pass into the URL of the iframe the username of the account currently logged into CRM. With the below js function I'm able to get the UserId and Name, but it's the Full Name, not the username on the account:
function createUrl() {
//var user = Xrm.Page.context.getUserId();
var user = Xrm.Page.context.getUserName();
var url = "http://myapp/app?user=" + user;
Xrm.Page.getControl('IFRAME_externalSite').setSrc(url);
}
the only solution I could find was to use the UserId from the Xrm.Page.context.getUserId() method and query the SystemUser Entities through OData and retrieve the username from there. Is there another way without querying the OData service?