I have repeatedly been asked by customers if I can remove the “Add Existing” button from associated views in CRM 4.0. There are times where it just does not make sense. There was no supported way to do this, although there were various JavaScript solutions which were a little (lot) messy.
Now with Dynamics CRM 2011 we have a fully supported way to interact with and change most aspects of the ribbon, including removing the add existing button. For today’s article I’ll step through how to remove the “Add Existing” button from the Contacts Associated view. First we will create a new solution to house our changes and add the Contact entity to this solution.
Navigate to Settings, Solutions and create a new solution. Give your solution a name, add a publisher, version and click save. I’ve called mine “Remove Add Existing Button”.
Next add the contact entity to your solution. We do this by navigating to Components within the solution and clicking “Add Existing” and Entity. Select the Contact Entity.
We are now ready to export your solution and edit the customisation.xml file. Click “Export Solution” and follow the prompts (Don’t select any other items to export as you navigate the prompts and select unmanaged as your package type).
Navigate to where you saved your solution zip file and unzip the it. Your unzipped directory should look like this.
Open the customisations.xml file. I would suggest using Visual Studio or an xml editor to edit this file. Search for the following section in the customisations.xml file:
<RibbonDiffXml>
<CustomActions />
<Templates>
<RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
</Templates>
<CommandDefinitions />
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules />
</RuleDefinitions>
<LocLabels />
</RibbonDiffXml>
We are going to replace the <CustomActions /> element with the following:
<CustomActions>
<HideCustomAction Location="Mscrm.SubGrid.contact.AddExistingStandard"
HideActionId="Sample.Mscrm.SubGrid.contact.AddExistingStandard.HideAction" />
</CustomActions>
Once we’ve done that, save and close your customisations.xml and add it back to your solution zip file, overwriting the existing customisations.xml file.
We can now re-import our solution file. Navigate back to CRM and Settings, Solutions and click “Import”
Step through the prompts and your solution will be re-imported. Once your import is successful, click “Publish All Customisations”
If you navigate to Accounts, select an account and then navigate to the associated contacts, you will see that the “Add Existing” button has been removed. Below you can see the “Add Existing” button in the Associated Contact view before we removed it.
and after we removed it.
You can use this concept for any entity. Repeat the above steps for the entity /entities you wish to remove the “Add Existing” button for and in the customisations.xml file for each entity replace “contact” with the name name of you entity under that entities <RibbonDiffXml> element as per the below.
<CustomActions>
<HideCustomAction Location="Mscrm.SubGrid.<entity name here>.AddExistingStandard"
HideActionId="Sample.Mscrm.SubGrid.<entity name here>.AddExistingStandard.HideAction" />
</CustomActions
For your reference I have attached the solution file I created for this example here: RemoveAddExistingButton_1_0_0_0.zip
I love the solution concept in 2011! Be warned this is an unmanaged solution and hence you cannot roll it back. Put it in a test or dev environment first!
3 comments:
How would I edit the "add existing button" in crm 4.0 to make it lookup on all crm records related records, not just active records? Very helpful post! Thanks!
I would like to also remove these buttons on the ribbon that appears when you click on a Sub-Grid added to the form. How do you reference the buttons related to a Sub-Grid?
Thanks!
Post a Comment