Blog
Customizing the Microsoft Dynamics CRM 2013 Ribbon – A recent experience
I was recently tasked with conditionally disabling the Deactivate button on the CRM Account form. The goal was to enable the button for select users, while disabling the button for the rest. This would prevent unauthorized users from deactivating an Account record.
Since this cannot be accomplished natively through security roles, the first step I did was add a new web resource with a Boolean javascript function that determined who the logged in user is. This function was added to the form onload event. The next step was to configure the RibbonDiffXml for the entity according to the SDK. I added my CustomAction and EnableRule which executed based on the result returned from my javascript function. I successfully published the solution to the CRM organization and tested, but the button wasn’t disabled! The troubling thing was that I received no error, which made it difficult to troubleshoot. I knew my javascript was working based on alerts I had previously added. After further research, I discovered the issue was the CommandDefintionID within the RibbonDiffXml. Instead of entering the correct command of “Mscrm.Form.Deactivate”, I had mistakenly used the ButtonId which was very similar: “Mscrm.Form.account.Deactivate”. After fixing the CommandDefinitionID and publishing the solution in CRM, it worked! Now when an unauthorized user opens the Account form, they will be unable to click on the Deactivate button:
Thanks for reading and I hope this experience will help others out there. For questions or more information on how to customize your Microsoft Dynamics CRM, please contact Beringer.