Sunday, October 09, 2016

What happens to the Data after an Extension is uninstalled in Dynamics NAV 2016 ? - Tips, Tricks & Facts #3

Hi Guys, After my last post on extensions, I got questions from my blog readers that,

What happens to the data if we uninstall an extension in NAV 2016? 

As in, If we uninstall the extension then what about the data in the fields which were packaged in that extension.

Take a look at the screenshot below,

After uninstalling the extension we can see some new tables in our database.

The new tables are marked in orange and the new fields are marked in blue in the image above.

One table is created in SQL per existing Company in the database and this happens only when you have added new fields in a table which was packaged in your extension.

Yes, the names of these newly created tables are confusing but each table name is prefixed with AppData. All the data which was in the fields which were packaged in the extension exists in these tables.

Before uninstalling the app, I created a Location card in NAV as shown below,

Take a look at the table data in SQL for this Location record (before the app was uninstalled),

Now, take a look at the table data in the new table which was created after uninstalling the app,

This newly created table has two set of fields in it,
  • Primary Key fields (of the table in which new fields were added).
  • New Fields which were packaged in the extension.
In my demo scenario, 3 fields are created in the new table
  • Code (Primary key of Location Table)
  • Created By (Added on ID 50000 in Location Table and then packaged in extension)
  • Created Date (Added on ID 50001 in Location Table and then packaged in extension)
And last but not the least, when I uninstalled my Location extension I left DoNotSaveData unchecked so that my data is saved in SQL. See the screenshot below to know How to uninstall an extension,

If I mark DoNotSaveData parameter as True when I uninstall my app then obviously my data will not be saved in SQL and obviously no new AppData prefixed name tables will be created.

Keep Learning!!
& don't forget to post comments and doubts in comments section, I will be happy to answer them!