Wednesday, March 23, 2022

How to get role name by using javascript

 function CheckUserRole(executionContext)

{

//debugger

var currentUserRoles = Xrm.Utility.getGlobalContext().userSettings.securityRoles;

for (var i = 0; i < currentUserRoles.length; i++)

{

var userRoleId = currentUserRoles[i];

var IsAdmin = IsAdministator(userRoleId);

if (IsAdmin == true)

{

break;

}

}

return IsAdmin;

}

function IsAdministator(roleId)

{

//get the globalContext

var globalContext = Xrm.Utility.getGlobalContext();

//get the rolesArray

var userRoles = globalContext.userSettings.roles;

//initialize return value

var hasRole = false;

//foeach item in array

userRoles.forEach(function hasRoleName(item, index)

{

//Check passed in value for role[].name match 

if (item.name === "System Administrator")

{

//match found set return value to true

hasRole = true;

};

});

return hasRole;

}


How to Deploy your API as a web app or API app

  Before you can call your custom API from a logic app workflow, deploy your API as a web app or API app to Azure App Service. To make your ...