Hello All,
I am using Following Javascript to get current role of User .
How should i enable and disable a button using below Js in Ribbon workbench .
Can anyone help me on this ? Thank you :)
function getUerRoles()
{
var roleid = Xrm.Page.context.getUserRoles();
var name;
for (var i = 0; i < roleid.length; i++) {
var roleID = roleid[i];
var RoleName = getRoleName(roleID);
if (RoleName == 'System Administrator') {
return true;
}
else
{
return false;
}
}
}
function getRoleName(roleID) {
var serverUrl = Xrm.Page.context.getClientUrl();
var OdataURL = serverUrl + "/XRMServices/2011/OrganizationData.svc" + "/" + "RoleSet?$filter=RoleId eq guid'" + roleID + "'";
var roleName = null;
$.ajax({
type: "GET",
async: false,
contentType: "application/json; charset=utf-8", datatype: "json",
url: OdataURL,
beforeSend:
function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success:
function (data, textStatus, XmlHttpRequest) {
var result = data.d;
roleName = result.results[0].Name;
},
error:
function (XmlHttpRequest, textStatus, errorThrown) {
// alert('OData Select Failed: ' + odataSelect);
}
});
return roleName;
}
*This post is locked for comments