Pages

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!

4 comments:

  1. what about migrating to extension.

    if we have a table with 3 new field and I what to create an extension without losing any data - is there a way we can use the logic of keeping the data deleting the fields and then install our new fields as an extension.

    ReplyDelete
    Replies
    1. Hi +Darmogill, thanks for your comment. Could you mention what is your actual requirement?

      Like mentioned in my post, the data is kept in other tables after you uninstall the app.

      Delete
    2. Hi Ishwar,
      Thanks for your prompt reply,

      I would like to upgrade business data from NAV 2016 to NAV 2016 + extensions.

      let say I have added a new filed to a standard Table in NAV 2016 and now on a different environment I have packed and install this extension on NAV 2016.
      is there a way I can migrate from a none extension environment to an environment with extensions (same code) without losing the business data ?

      Delete
    3. I will answer your question after some research. Thanks for putting up this interesting question.

      Delete