Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 9244

Retrieve user name and and security role for that user

$
0
0

I need to disable a field for users who don't have a certain security role via javascript.

So far I have got the user ID of the person:

// Get user ID
var userID = Xrm.Page.context.getUserId();
alert (userID);

Searching for the answer on the forums I can see various examples such as:

 // Set Global Variables
  serverUrl = context.getServerUrl();
  userId = context.getUserId();
  ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";

  var retrieveReq = new XMLHttpRequest();
  retrieveReq.open("GET", ODataPath + "/RoleSet?$select=Name&$filter=RoleId eq guid'" + roleId + "'", true);
  retrieveReq.setRequestHeader("Accept", "application/json");
  retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  retrieveReq.onreadystatechange = function () {
    retrieveRoleNameReqCallBack(this);
  };
  retrieveReq.send();

However this and the other examples fail - I am new to javascript so a little out of my depth at the moment.

regards,

Matt


Viewing all articles
Browse latest Browse all 9244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>