NAV2018: VSCode UpgradePerCompany/Database

maze93maze93 Posts: 11Member
Hi all,

It seems that when you republish an extension from VSCode (CTRL +F5) all the data inside the tables of your extension is removed.
I've read all there is to read about upgrade codeunits but it does not seem that OnNavAppUpgradePerCompany and OnNavAppUpgradePerDatabase works yet for extensions (with the use of NAVAPP.RestoreArchiveData of course)?

Last update I could find about this can be found here: https://github.com/Microsoft/AL/issues/62

Does anyone else have any information when we can expect this feature? If we can't upgrade our data then we can't republish any extensions (even if both publications are identical) which means we can't use extensions :-)

Thank you!

Regards from Mattias

Answers

  • DenSterDenSter Posts: 8,111Member
    That issue is not about upgrade codeunits but about running the extension in a dev environment. Currently when you run, then add some data, then run again, the app loses its data. In that case, the upgrade codeunit does not run.

    If you deploy a new version of your .app file, and you run the proper powershell to deploy it (publish-navapp, then sync-navapp, then start-navappdataupgrade), the upgrade codeunit does run. I ran one myself this morning and it ran as expected. Here's a link that explains the process: https://docs.microsoft.com/en-us/dynamics-nav/developer/devenv-upgrading-extensions
  • maze93maze93 Posts: 11Member
    @DenSter so you mean I shouldn't deploy from VsCode with CTRL F5 bit use Powershell instead? Do you think it would work if i deploy through VsCode and then run sync and dataupgrade from Powershell? Or only via Powershell?

    Thanks!
  • maze93maze93 Posts: 11Member
    Has anybody got any more information regarding this? Do we know when we can expect the issue to be resolved? Since it was not resolved in CU1, hopefully in CU2? Seems odd that Microsoft forgets to implement one of the most needed functions...
  • DenSterDenSter Posts: 8,111Member
    I don't think it's a matter of them *forgetting* about it, and it's a matter of your point of view whether it is even considered to be *an issue*, maybe from their point of view it works exactly the way they want it to work. It kind of makes sense to redeploy rather than upgrade, so that you are totally free to make any type of destructive change in your dev environment.

    If you want the upgrade codeunit to run, you have to run it through powershell. Deploying your app from VSCode does not run the upgrade codeunit. It does run the Install codeunit though, so if you need some data setup you can put that there.
  • DenSterDenSter Posts: 8,111Member
    Update: they put in a new property for launch.json called 'schemaUpdateMode'. Set it to 'recreate' and it will rebuild the table and you lose your data. Set it to 'Synchronize' and you get to keep your data between F5's. Very useful :)
  • maze93maze93 Posts: 11Member
    Hi @DenSter

    I wonder if they will put in a "Force"-property to not loose any data. We will see...
  • DenSterDenSter Posts: 8,111Member
    I don't understand your point. You keep your data by setting the schemaUpdateMode to Synchronize. Not sure what that property would do in addition to that
  • maze93maze93 Posts: 11Member
    Hi @DenSter

    In cases where you need to i.e. remove a field from a table, change the field type or such things, but want to keep the data. I get that you can use an upgrade codeunit for this, so it is possible to solve but that is what I mean.

    Rgds from Mattias
  • DenSterDenSter Posts: 8,111Member
    I still don't get it. You need a field to keep data. Doesn't make sense to remove the field if you want to keep the data. Anyway, the SchemaUpdateMode property is not relevant for actual upgrade scenarios, it's only relevant for how the app deals with tables.
Sign In or Register to comment.