Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Run JS on Editable Grid row delete

(0) ShareShare
ReportReport
Posted on by

There's on change, and on save, but neither triggers on a row delete. I want to run a JS on the form when a row has been deleted from the Editable Grid using the trashcan icon on the furthest right of the row. Is this possible, somehow? Please note: editable grid, in 365, not standard grid.

*This post is locked for comments

  • Suggested answer
    Sahil Agarwal Profile Picture
    on at
    RE: Run JS on Editable Grid row delete

    Normally when record is created or deleted, the subgrid will refresh so I register a event when grid refresh

    Try this.

    function mainForm(executionContext) {

       var formContext = executionContext.getFormContext();

       //add event when grid is refresh after add or delete a record

       formContext.getControl('subgrid logical name').addOnLoad(function(formContext){

           //total record present in grid before delete

           var totalRecord = formContext.getControl("subgrid logical name").getGrid().getTotalRecordCount();

           //Check row is deleted or not

           //if deleted then perform js

           if(formContext.getControl("subgrid logical name").getGrid().getRows().get()[totalRecord-1] == undefined){

               //action

           }

       });

    }

  • awalters Profile Picture
    3,079 on at
    RE: Run JS on Editable Grid row delete

    I don't suppose you ever found a way to do this?  I've got the exact same issue right now.  I have a plugin recalculating a rollup when the child records are added/changed/deleted, but I need the screen to reflect that.  I can get it to trigger via javascript when a record is added (via a listener on the grid onload), and when a record is changed (via the onSave event on the grid), but neither of these trigger when the record is deleted on the editable grid.  :-(  I also thought about a custom delete field/button/something - but there doesn't seem to be a way to get rid of the OOTB delete icon.  Not even removing the user's permissions to delete!  So I can't find a good way to add a custom delete that isn't confusing, given the OOTB one also being there.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Run JS on Editable Grid row delete

    Hi Erik,

    in that case,

    Normally when record get created or deleted, the subgrid will refresh, you can take a  look in below post. copy the code from below post too.

    community.dynamics.com/.../271605

    Because V8.2 , we are not allowed to delete the record in editable subgrid.

    So i only made a create record video for you.

    https://youtu.be/kNxxg_HeoCc

  • Community Member Profile Picture
    on at
    RE: Run JS on Editable Grid row delete

    Hi all, thanks for the replies.

    I have a custom HTML iframe which contains summarized data from the editable grid.

    I want this iframe to reload on grid row deletion.

    Had it been a standard subgrid, there is an onload listener. Sadly it's not available for editable grid.

    I'm thinking I might have to add my own custom Delete button...

  • Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Run JS on Editable Grid row delete

    Hi Erik,

    would you mind to share what do you want to achieve via JS?

  • Community Member Profile Picture
    on at
    RE: Run JS on Editable Grid row delete

    Hi Erik,

    I'm not too familiar with JScript on Editable grids, but I would like to suggest an answer:

    Add custom field to the entity form the grid is sitting on. Set a real-time workflow in place that uses the "Record is Deleted" trigger, once triggered, it updates the parent record's custom field. This field can hold a value that your JScript function can use to reference when utilized OnLoad, OnSave or OnChange.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans