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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Confirming Data Change on a Form

(0) ShareShare
ReportReport
Posted on by

I would like to know the regular code for confirming data change on a form before they are saved. As an example, I need to let the user to confirm the change if he change statement method to "Shift" from the default value "Date and time", If he hit Yes, continue the change, otherwise, revert the change. My code snippet shows like this:

public void modified()

{

   //[kl]

   if (statementTable.closingMethod != RetailClosingMethodType::DateTime)

   {

       if (box::yesNo("WARNING: you are attempting to calculate this statement using the 'Shift' closing method. Do you wish to proceed?", dialogButton::Yes, "Confirm changes")

       == dialogButton::No)

       {

           statementTable.closingMethod = statementTable.orig().closingMethod;

           return;

       }

   }

   super();

   statementTable_ds.refresh();

}

Can you comment on, or correct?

*This post is locked for comments

I have the same question (0)
  • Gertjan Profile Picture
    1,200 on at

    Do you need to confirm data changes for all forms or for one specific scenario? If you prefer a confirmation for all forms you can use the confirmation options in the user options form. There you can define if you want to ask for confirmation before saving changes. You can choose this per type of data (main, parameters and so on).

    If you only need confirmation for some specific fields you could use the validate method on the data source on the form. If the question is answered with 'No' you return 'False' and your data is not changed. In this case you do not need to reset the value to the original value yourself. I suggest you make this change on the form to be absolutely sure that you can safely show a dialog box. If you would use validateField on the table itself you cannot be sure if there is a user interface available during the change.

  • Suggested answer
    Community Member Profile Picture
    on at

    easiest way would be, implement all  you logic in forms datasource Write method and call the super() of Write method only when your condition is true.

    Like this

    public void write()

    {

       if (statementTable.closingMethod == RetailClosingMethodType::Shift)

      {      

          if (box::yesNo("WARNING: you are attempting to calculate this statement using the 'Shift' closing method.  Do you wish to proceed?", dialogButton::Yes, "Confirm changes")       == dialogButton::Yes)

          {

              super();

          }

      }

    }

    This logic

    please validate, hope this will work

  • Community Member Profile Picture
    on at

    Thanks for the comments

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans