web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

executionContext.getEventArgs().preventDefault() not working in editable grid save event in model driven apps

(0) ShareShare
ReportReport
Posted on by 66

Hi ,

I have opportunity forecast custom entity on opportunity with editable control registered on it. on save event of editable grid of forecast have a JS function which take user confirmation using navigation.confirmDialog method.

but on cancel , I have written executionContext.getEventArgs().preventDefault(); Ideally, this should stop the save operation of editable grid but it is not stopping this and save operation is happening.

Can anybody suggest the way by which I can achieve this ?

I have tried some of the post related to this which shows how to handle it by add an additional flag but it has not worked for me 

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: executionContext.getEventArgs().preventDefault() not working in editable grid save event in model driven apps

    Hi partner,

    I spent some time to test in my instance and I found that confirmDialog is not the reason, "preventDefault" method is not supported in editable grid.

    For example I only put the  "preventDefault" in the onsave event and it will still save successfully after I clicked the save button on grid.

    function savePrevent(executionContext) {
        var EventArgs = executionContext.getEventArgs();
        EventArgs.preventDefault();
    }

    In my opinion, the reason for this should be that "preventDefault" method is uesd in a special record form to prevent the saving of one record. But when we click on the save button in editable grid, it will save mulitple records which may not be supported by "preventDefault".

    Editable grid is able to change the information of each record at any time, even if the wrong data can be easily corrected immediately, so there is no need to consider cancelling this operation.

    Hope it helps.

    Best Regards,

  • Sumit Desai Profile Picture
    66 on at
    RE: executionContext.getEventArgs().preventDefault() not working in editable grid save event in model driven apps

    Hi Leo,

    Thanks for you clarification. It helped me to confirm that prevenDefault is not working in editable grid.

    Basically we want to get confirmation from user with OK and Cancel button when there is a change in a data of any field on editable grid therefore we are  using navigation confirmdialog here; dialog is appearing but irrespective of user click on OK or Cancel SAVE operation is happening that should only be happened if user click  on Ok button on cacel should be reverted to original value.

    This issue arise when we migrated from web client to UCI.

    We were using XRM.Utility.confirmDialog and it was working as expected means save operation execution holds until response from confirmation  dialog and if user select the cancel it stops completely.

    This is what our complete scenario is. Hope you understand this .

    Thanks in advanced.

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: executionContext.getEventArgs().preventDefault() not working in editable grid save event in model driven apps

    Hi Desai,

    Thanks for your explanation.

    That seems to be a technical limit at the moment, so we could not prevent saving in the editable grid in UCI.

    You could raise an idea here or raise ticket to Microsoft Team for more professional help.

    Best Regards,

    Leo

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: executionContext.getEventArgs().preventDefault() not working in editable grid save event in model driven apps

    Him

    you can build a plugin and workflow as a alternative solution.

    throw the error if condition met.

    docs.microsoft.com/.../use-invalidpluginexecutionexception-plugin-workflow-activities

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 125

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 121 Super User 2025 Season 2

#3
Erin Lubben Profile Picture

Erin Lubben 73

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans