Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Regaining Original val...
Finance forum

Regaining Original values that a record has before the update is done in dynamics 365

(0) ShareShare
ReportReport
Posted on by 290

Hi Experts,

In my line table having five lines with Quantity field, I'm updating these lines field to zero. If any one of line getting error(suppose line 3)

so I want to cancel this update and regain original values of the lines. Can any one suggest me about this.

Thanks

Tanmay

  • Tanmay Upgade Profile Picture
    290 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Thanks It worked for me.

  • Community Member Profile Picture
    on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Attach the debugger and make sure that the orig() record is committed to the database before the error is thrown. The orig() should return the values that were at the start of the operation rather than the updated values. Make sure you are properly terminating your transaction via the ttsCommit keyword.

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    What exactly is not working? Please share more details.

    The .orig() returns and object of type Common so it doesn't contain references to your fields. Instead you must do like Danyal already instructed:

    YourTable yourTable_orig = this.orig();
    
    [...]
    
    yourTable.YourField = yourTable_orig.YourField;


  • Tanmay Upgade Profile Picture
    290 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Yes I tried but it's not working.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Did you try adding the Field and then building your solution?

    Otherwise your could do this

    TableBuffer buffer = Table.orig();
    
    // now use buffer.Field


  • Tanmay Upgade Profile Picture
    290 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Hi,

    MyTable.Field = MyTable.orig().        ;

    Cannot find Field after orig() method.

  • Mea_ Profile Picture
    60,278 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    You can use orig only before super() of update, where do you have it ?

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Hi TanmayU,

    You are on the right path and orig() is the solution to your problem, just call it when an error occurs to update the value. or you could achieve this manually by keeping a copy of the reference at the start of the operation and update your value with that copy when an error occurs.

  • Tanmay Upgade Profile Picture
    290 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Hi ievgen,

    I am trying to use orig() method to get the previous state of field but its not happening in D365 and same is working in AX 2012.

  • Suggested answer
    Mea_ Profile Picture
    60,278 on at
    RE: Regaining Original values that a record has before the update is done in dynamics 365

    Hi Tanmay U,

    If you updating them from code then just use transaction wrapping all updates with ttsBegin; ttsCommit; In this case error inside of the transaction will rollback all changes.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,925 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans