Security trimmed ribbon elements

In this recipe, we will be looking at dynamically removing a ribbon button when a certain condition is met. First off, we'll create a function to check for the condition. If the condition is met, a second function is called that hides an existing button. So let's get started.

Getting ready

For this recipe we can either use an existing solution, or create a new one. Make sure you have permissions to make customizations in the system.

How to do it...

For the sake of simplicity, we check to see if the current user is the owner of a contact, and if not, we hide the Save button. You can do the same with the Save and Close button, as well as any other ribbon buttons.

  1. Create a new solution or open an existing one.
  2. Add the ...

Get Microsoft Dynamics CRM 2011 Scripting Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.