Tuesday, 6 September 2016

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


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() {
    modifySubgridDeleteButtonEventHandler("subgrid_name_in_the_form", deleteSubgridRecord, true);

function deleteSubgridRecord() {

function modifySubgridDeleteButtonEventHandler(subgridName, functionToCall, passGridControl) {
    try {
        //to store the original function ones
        var originalFunctionDeleteRecordSubgrid = Mscrm.GridCommandActions.deleteRecords;
        //add new standard subgrid
        Mscrm.GridCommandActions.deleteRecords = function (selectedControl, selectedControlSelectedItemReferences, selectedEntityTypeCode) {
            //if (typeof (gridControl.get_id).toString().toLowerCase() == "undefined") {} //no need since I replaced by the previous line
            if (selectedControl.get_id() != subgridName) {
                originalFunctionDeleteRecordSubgrid(selectedControl, selectedControlSelectedItemReferences, selectedEntityTypeCode);
            else {
                if (passGridControl) {
                else {
    catch (e) {



*After clicking the ‘Delete’ button


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



  1. It is very helpful to each one. your point of view is the best among many. thanks for posting.I found your blog the most informative one .thanks for providing it as it helped me a lot in grooming my knowledge.On the off chance that you need a noteworthy impact in your neighborhood, publicizing can raise your association's profile and pass on results. Ad spot advertisements put your message specifically before your potential customers. OOH Advertisement ERP is not just about tremendous sheets for the road. There are distribution goals and sizes to suit every single monetary arrangement.

  2. Your blog post is very informative and helpful one. I learned useful information about how to modify the Delete button in the CRM Subgrid.I am Ms Dynamic CRM consultant and its really very helpful information for me.

  3. Nice article really informative for me as on this I’ve found some best results for
    SuiteCRM Customization
    As this found the best services for crm integration
    SugarCRM integration Services
    CRM Integration

  4. Actually this information was quite interesting on content marketing. As we heard about the quality content fresh content bla bla like that. Yes i agree with that one but apart from that we have to make the news in which they are looking for. Okay i am satisfied with your posts. Thank you

    SEO Company in India

  5. Hi,

    Many thnaks for your article. It works fine on 1:N relationship, but on N:N it doesn't work, do you know why ?



My Name is..