
I am currently using a script to check a users role and then disable certain fields with javascript, like so:
Xrm.Page.getControl("address1_line1").setDisabled(true);
Is there a way to this with the deactivate button?
I've read you can download Ribbon editors, but that doesn't really appeal to me as I already have all the logic in place in my script regarding what roles can access what. It would be a lot simpler to manage everything in one place. If it's not possible, what's the recommended way to edit the ribbon?
*This post is locked for comments
I have the same question (0)The ideal way is to use a ribbon editor - Ribbon Workbench is the best choice. From there you can create an enable rule on the button that calls a JavaScript function from a web resource (so maybe you can re-use what you've already created). The function would return a boolean value to indicate ithe state of the button. The reason for making these changes in the ribbon as opposed to in script defined in the form properties is that the SDK doesn't provide a supported mechanism to reference a control in the ribbon directly. Yes you could probably inspect the source of the page and get the Id of the control and work some JavaScript to disable it but that isn't supported. Unsupported meaning Microsoft could out of the blue one day decide to change the Id of the control and your code would break. Since they haven't documented a means to access the ribbon controls from the form they aren't really obligated to announce such a change.