How to override System Ribbon Button in CRM 2011 ( Display / Enable Rule to System Ribbon Button in CRM 2011)?
How to show / hide a system button based on a value on the form?
In CRM 2011, it is possible to override the System ribbon button functionality. Also we could apply Enable / Disable Rule Display / Hide Rule to the existing System Ribbon button.
In order to grasp this quickly, lets consider a scenario.
As we all know, there is a Deactivate system ribbon button on the Account form.
Suppose we would like to Enable / Disable this button based on a value on the Account form. To make it simple, lets consider the City field.
There is a key to unlock the door here. what is that key ? Lets see.
If you refer the SDK, you could find the following folder and file
Lets find out our System Deactivate button.
Please Note: We don't need to write the following piece of code. This is just an easy way to refer and then to find the key from SDK.
<Button Id="Mscrm.Form.account.Deactivate" ToolTipTitle="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" ToolTipDescription="$Resources(EntityPluralDisplayName):Ribbon.Tooltip.Deactivate" Command="Mscrm.Form.Deactivate" Sequence="60" Alt="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" LabelText="$Resources:Ribbon.HomepageGrid.account.Record.Status.Deactivate" Image16by16="/_imgs/ribbon/deactivate16.png" Image32by32="/_imgs/ribbon/Deactivate_32.png" TemplateAlias="o2" />
Now can you guess what's the key in this? Its nothing but the Command.
The only key thing we need to override the System Ribbon button is to know the command value. Rest is as easy as we open a door with a valid key. We need to write the CommandDefinition as shown below.
Please make sure that the code is written under right parent tags.
Also the enable rule under rule definitions as show in the above picture.
<ValueRule Field="address1_city" InvertResult="false" Value="London"/>
Here we go.
Scenario1: City value is not London -- Deactivate Button got disabled.
Scenario2: City value is London -- Deactivate Button got enabled.
Scenario3: City value is London -- Deactivate Button was clicked by the user. (alert from custom js function)
As this is my first post in 2012,
"тнєяє ѕнαℓℓ вє ѕнσωєяѕ σƒ вℓєѕѕιηg тσ уσυ αℓℓ ιη тнє вℓσωιηg ƒℓσωєя -2012"