You use upgrade codeunits when you make changes to a table definition, either from the Microsoft Dynamics NAV Development Environment or during an upgrade. Upgrade codeunits migrate existing business data from the old table structure into the new table structure. An upgrade codeunit serves the following purposes:
- Provides instructions for how to handle data changes to a table during schema synchronization. For more information, see Synchronizing Table Schemas.
- Provides the logic for migrating existing data in the business data table from the old format to the new format after schema synchronization.
- Provides instructions for updating custom report layouts to dataset changes. For more information, see Updating Custom Report Layouts by Using Upgrade Codeunits.
A typical example of when to use an upgrade codeunit is when you remove a field from a table definition and you do not want to lose the existing data in the business data table. Instead, you want to use it somewhere else in the new application.
You implement upgrade codeunits when you make destructive changes to tables in Microsoft Dynamics NAV Development Environment. For more information about destructive changes, see Handling Destructive Changes With Table Schema Synchronization. After you have created an upgrade codeunit to handle table changes, you can use it when you upgrade data from an earlier version of Microsoft Dynamics NAV to the current version. A single upgrade codeunit will typically contain table schema synchronization instructions and data migration logic for multiple tables that have changed from one version of Microsoft Dynamics NAV to another. More…