|
![]() |
#1 |
Участник
|
CRM DE LA CREME! Enabled and disable fields based on a user role
Источник: http://crmdelacreme.blogspot.com/201...-based-on.html
============== All had a question to see if this could be done and this is the code that was used to enabled and disable fields based on a user role when a value is changed in a list box change event. function UserHasRole(roleName) { //get Current User Roles, oXml is an object var oXml = GetCurrentUserRoles(); if(oXml != null) { //select the node text var roles = oXml.selectNodes("//BusinessEntity/q1:name"); if(roles != null) { for( i = 0; i < roles.length; i++) { if(roles[i].text == roleName) { //return true if user has this role return true; } } } } //otherwise return false return false; } function GetCurrentUserRoles() { var xml = "" + "" + "" + GenerateAuthenticationHeader() + " " + " " + " " + " role" + " " + " " + " name" + " " + " " + " false" + " " + " " + " roleid" + " role" + " systemuserroles" + " roleid" + " Inner" + " " + " " + " systemuserid" + " systemuserroles" + " systemuser" + " systemuserid" + " Inner" + " " + " And" + " " + " " + " systemuserid" + " EqualUserId" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + ""; var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction"," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml); var resultXml = xmlHttpRequest.responseXML; return(resultXml); } //This is the code used to enable or disable the fields in CRM 4. try { if(crmForm.all.isp_goodwill.DataValue == '1') //List box selected = yes { if(UserHasRole("Goodwill Manager")) //Role to look for { //Fields to enable. crmForm.all.isp_goodwillrequestedbyid.Disabled = false; crmForm.all.isp_goodwillapprovedbyid.Disabled = false; crmForm.all.isp_goodwillvalueapproved.Disabled = false; } } } catch(e) { alert(this.gErrorMessage("Authorisation Form",e.description )); } Источник: http://crmdelacreme.blogspot.com/201...-based-on.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|