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 :
Microsoft Dynamics AX (Archived)

How prevent saving a record while closing the form

(0) ShareShare
ReportReport
Posted on by 55

when i am closing the form record will be saved.

How prevent saving a record while closing the form ?

thanks,

Khadar Shaikh

*This post is locked for comments

I have the same question (0)
  • Chaitanya Golla Profile Picture
    17,225 on at
    RE: How prevent saving a record while closing the form

    Hi,

    Could you provide some more details about your requirement as many other actions/events on the form grid saves the record before closing the form.

    Thanks,

    Chaitanya Golla

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How prevent saving a record while closing the form

    Closing the form will save the record, which is the intended business functionality.

    In case you want to close it without saving, there already is a feature for that, which is pressing the <ESCAPE> key, and confirming in the dialog you want to close without saving.

    "If it ain't broke, don't fix it."

    I presume this is how you would like to prevent unintended user actions. The correct solution is to set up security for them appropriately, so they would not be able to modify records which they are not supposed to!

    If you still intend to break the default business logic, you could try to override the close() method on the form, do not call super(), but call element.closeCancel() instead, which is the equivalent of pressing escape. See how that works since I did not test it, but the solution should be somewhere along those lines.

    If you do that, please realize that regular users who fill out the data and close the form without specifically pressing save or navigating away from the record would expect that the record changes are saved which you have now broken, would be upset.

  • khadar shaik Profile Picture
    55 on at
    RE: How prevent saving a record while closing the form

    Hi Vilmos Kintera,

    I was try to override the close method by calling element.closecancel() without super.

    but it is still saving the record.

  • khadar shaik Profile Picture
    55 on at
    RE: How prevent saving a record while closing the form

    Hi Chaitanya,

    When we are crated a record on form and its not saved, i am closing that form by using 'X' button the record is saving. it is standard behaviour of a form. but in my case i don't want to save the record when i am closing the form.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How prevent saving a record while closing the form

    Then it is technically not feasible. You need to solve this by the correct approach, and set up Security right.

    Or if you do not want record manipulation at all, why not just set up AllowInsert and AllowEdit = No on the form datasource?

  • Suggested answer
    fatihgork Profile Picture
    3,817 on at
    RE: How prevent saving a record while closing the form

    Hi Khadar,

    You can configure AX to open a dialog for confirmation before commiting updates.

    It might help with your requirement or at least might provide you a different starting point.

    The setting is located in Options form and this form can be reached by following this path: File/Tools/Options

    Please check Confirmation tab for "Confirm update" settings

  • Community Member Profile Picture
    on at
    RE: How prevent saving a record while closing the form

    In form data source method override write method and write this code

    public void write()

    {

       if(element.closedOk())

       super();

    }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans