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 ?


  6. I read so many articles in your blog. All are awesome. I learnt a lot of new things with help of your blog. Thanks for sharing this wonderful information.
    Web development company in bangalore
    Web design company bangalore
    Ecommerce Website Design and Development Company in Bangalore
    Outsource magento ecommerce services india


  7. شركة غسيل خزانات بالمدينة المنورة و عمال مروبون وحاصلون على شهادة صحية فقط اتصل بنا لتحصل على افضل خدمة غسيل خزانات

  8. Really nice and definitely it will be useful for many people. Kindly keep update like this.

    Manufacturing ERP
    Human Resources Management Software
    CCTV Camera Dealers in Chennai

  9. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work.
    Digital Marketing Company in Delhi
    SEO Services in Delhi
    SEO Company in Delhi


  10. بسم الله الرحمن الرحيم عميلنا العزيز نحن نقدم افضل خدمات تنظيف المجالس والشقق بافضل انواع التنظيفات المشهود لها عالميا
    شركة تنظيف مجالس بالطائف
    شركة تنظيف مجالس بجازان
    شركة تنظيف مجالس بحائل
    ونحن فى خماتكم 24 ساعة على مدار الشهر


My Name is..