O'Reilly logo

Microsoft Dynamics NAV 2009 Programming Cookbook by Matt Traxinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing your own rollback routine

NAV does some rollback automatically. But if there is a COMMIT statement in the code, only the changes after the COMMIT statement is executed will be reversed by the system. This recipe will show you how to leverage a built-in NAV feature called the Change Log to build your own rollback routine for those cases.

Getting ready

Turn on the Change Log for table 36, Sales Header.

How to do it...

  1. Create a new codeunit from Object Designer.
  2. Add a function named FilterRecord that takes in the following parameters:

    Name

    Type

    Subtype

    ChangeLogEntry

    Record

    Change Log Entry

    PrimaryKeyIndex

    Integer

     

    RecRef

    RecordRef

     
  3. Add the following local variables to the function:

    Name

    Type

    Length

    FieldRef

    FieldRef

     

    TypeNumber ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required