Modify the Delete (Dustbin icon) Button in the CRM Subgrid

Modify the Delete (Dustbin icon) Button in the CRM Subgrid

Overview

Sometimes we need to modify the Delete button in the CRM Subgrid, example:

1. For preventing users to perform the delete button (but you dont want to just disable it)

2. Call another function or call custom function that needs client site programming (We can do plugin onDelete or onAssociate, but in case you want to show it in the client site)

3. To do impersonation

The Code

function modifyRibbon() 

function deleteSubgridRecord() 

function modifySubgridDeleteButtonEventHandler(subgridName, functionToCall, passGridControl)  //no need since I replaced by the previous line
            if (selectedControl.get_id() != subgridName) 
            else 
                else 
            }
        }
    }
    catch (e) 
}

Result

*After clicking the ‘Delete’ button

image

Note: This method is overwriting the CRM functions and it works for CRM 2013, for CRM 2015/2016, this function [Mscrm.GridCommandActions.deleteRecords] might have been changed, so need to find out the current function name based on your CRM Version. And again, it means it is unsupported Smile

Thanks!