Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Data commit on form issues, undo feature?

Posted on by 150

I have a strange request I'm trying to figure out how to best solve. A user wants to open a form with one datasource, and make a bunch of changes, then clicks either OK or Cancel to save or revert those changes.

Conceptually, I'd like to just put ttsbegin in the "init" method, then in the "close" method either ttscommit or ttsabort based on the close action (ok/cancel).

The problem is the table is a permanent table, and the form wasn't designed with a temporary data source or anything, and there's a decent amount of logic associated with the table.

What's the best way to give the user this ability? Am I just stuck taking mytable.setTmp()?

*This post is locked for comments

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Data commit on form issues, undo feature?

    You will just create an issue for yourself, because smart user can simply terminate the client or it can crash, so records are saved already. The only one way to avoid such issues is to save data when needed instead of delete it.

  • Wmyk Profile Picture
    Wmyk 150 on at
    RE: Data commit on form issues, undo feature?

    I was pretty sure I couldn't wrap in a transaction, but I was trying to think of a clever way other than a temp table, simply because imagine the form was SalesTable and the user wanted that ability. I don't think it's an easy task to swap out to a temp table.

    I'm thinking maybe on closeCancel, loop over the table buffer on the form looking for MyTable.orig().RecVersion != MyTable.RecVersion, then setting all the key fields back to MyTable.orig().[whatever]...I'm thinking this could work.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Data commit on form issues, undo feature?

    Hi Wmyk,

    I don't think that you would be able to simple wrap form in a transaction, its probably technically not possible, so instead of wasting your time, just use temp table on the form and then dump it to real one on form close. This solution is well-known and can be supported by other people.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans