When an assumption is made that something very basic, can be easily configured using OOB functionalities, that is when I find myself stuck occasionally and having to rethink on how to implement a feature. I recently had one such experience. The requirement was to allow users in certain security role, to delete opportunity products, but not opportunities.
My first thought was to use security role, to modify the permissions for opportunity products. To my surprise, I was unable to find opportunity products in Security Role.
It turns out Opportunity Product, Invoice Product, Quote Product and Order Product share a unique trait: they don't have separate permissions and use the permission of their parent. Such being the limitation, I could implement this using ribbons or plugins. I implemented this using ribbon. Here are the steps
I did this on a CRM2011 organisation, but the process in same for a CRM2015 organisation. You'll just be editing the command bar instead of the ribbon. Here are the relevant buttons in CRM2015, whose command you'll need to edit.
My first thought was to use security role, to modify the permissions for opportunity products. To my surprise, I was unable to find opportunity products in Security Role.
It turns out Opportunity Product, Invoice Product, Quote Product and Order Product share a unique trait: they don't have separate permissions and use the permission of their parent. Such being the limitation, I could implement this using ribbons or plugins. I implemented this using ribbon. Here are the steps
- Grant Delete permission on the Opportunity entity for the appropriate security role
- Use Ribbon Workbench to edit the ribbon for opportunity entity
- Add a new Enable Rule of type Custom Javascript Rule. I am calling a function in the Javascript webresource
- Add the Enable Rule to the following commands:
- Mscrm.DeletePrimaryRecord
- Mscrm.DeleteSelectedRecord
- Mscrm.HomePageGrid.DeleteSplitButtonCommand
var CVN = window.CVN || {}; CVN.getOppDeletePermissionByRole = function() { return !XrmServiceToolkit.Soap.IsCurrentUserRole('1.1 CRM - Base User Role'); }; window.CVN = CVN;
I did this on a CRM2011 organisation, but the process in same for a CRM2015 organisation. You'll just be editing the command bar instead of the ribbon. Here are the relevant buttons in CRM2015, whose command you'll need to edit.