-
Book Overview & Buying
-
Table Of Contents
Microsoft Dynamics CRM 2011 Scripting Cookbook
By :
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.
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.
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.
Create a new solution or open an existing one.
Add the Contact entity to your solution of not already added.
Add a new web resource of type Jscript.
Add the following function to check if the current user is the owner of the record:
function HideButtonIfNotOwner(context)
{
var _currentUser = Xrm.Page.context...
Change the font size
Change margin width
Change background colour