Contact Us Today!

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:

DisabledDeactivateButton

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.


theProfessor

theProfessor

Rob is the CTO of Beringer Technology Group, and focuses his efforts on software development, cloud engineering, team mentoring and strategic technical direction. Rob has worked with Beringer since 2005, and has influenced every department from Development, Security, Implementation, Support and Sales. Rob graduated with his MBA from Rowan University in 2012, earned his Bachelors of Computer Science in 1997, and is current with several Microsoft technical certifications. Rob is very active, and loves to mountain bike, weight train, cook and hike with his dog pack.