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 :
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

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    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.

  • Tanmay Upgade Profile Picture
    290 on at

    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
    Community Member Profile Picture
    on at

    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.

  • Mea_ Profile Picture
    60,284 on at

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

  • Tanmay Upgade Profile Picture
    290 on at

    Hi,

    MyTable.Field = MyTable.orig().        ;

    Cannot find Field after orig() method.

  • Verified answer
    Community Member Profile Picture
    on at

    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

    Yes I tried but it's not working.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    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;


  • Community Member Profile Picture
    on at

    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.

  • Tanmay Upgade Profile Picture
    290 on at

    Thanks It worked for me.

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 > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans