回答

6

如果你說的是SystemUser記錄的FullName屬性,你可以使用此功能:

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

參考:CRM Answers - Get current user's full name with a synchronous call

2
Xrm.Page.context.getUserId(); 

這將返回當前用戶的GUID得到的用戶名(不是所有者)。
用檢索到的GUID查詢用戶實體以檢索與該用戶關聯的名稱和任何其他細節。