Import-NAVData to a new tenant and/or instance fails when the .navdata file contains an unpublished Designer extension
This is a new issue to reproduce the bug discussed in closed issue https://github.com/microsoft/AL/issues/4217
Describe the bug When exporting a .navdata file from a tenant or single tier service instance that contains an unpublished designer extension, the Import-NAVData process will fail when importing the .navdata file to a new tenant/instance if the designer extension is missing in the target.
To Reproduce In a multi-tenant environment with one tenant ("tenant1"), do the following:
- Run the in-client designer on tenant1 and add a field to a page. Save the designer extension.
- uninstall and unpublish the designer extension from tenant1
- Create a new empty tenant db called "tenant2" and mount it to the same multi-tenant instance. publish/sync/install all the same extensions that are published in tenant1. Note we will not publish the designer extension that was previously created and unpublished in tenant1, since it's "gone" forever for all intents and purposes.
- Run Export-NAVData on tenant1
- Run Import-NAVData on tenant2 to import the .navdata file into it. The import will fail with an error similar to this:
Import-NAVData : Cannot import the data because the specified file contains the following extension that has not been synchronized to the database: name=Designer_544cc16c-942a-4869-bcfb-cdd628d2b9f3,
publisher=Designer, version=1.0.0.0.
+ Import-NAVData -ServerInstance $ServerInstance -tenant $TargetT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (0:Int32) [Import-NAVData], FaultException`1
+ FullyQualifiedErrorId : MicrosoftDynamicsNavServer$BC16-NA-MT-Sandbox/clone-markfulcher-2,Microsoft.Dynamics.Nav.Management.Cmdlets.ImportNavData
Expected behavior
Import-NAVData should not fail on missing extensions in the target database where the missing extensions do not contain any table objects nor tableextension objects (as is the case for designer extensions since they'll only contain pageextension objects). Theres no reason to error out on a missing designer extension if there is no table/tableextension data for it.
Furthermore, since the designer extension is unpublished in tenant1, it is not possible to query these unpublished extentions via the development shell. The only way is to interrogate the following tables via SSMS and remove the designer extensions manually from the following tables:
- [$ndo$navappuninstalledapp]
- [$ndo$navappschematracking]
For unpublished extensions in tenant1, Sync-NAVApp -mode clean to purge the unpublished extension from tenant1 before running export-navdata is a legitimate solution for unpublished extensions that contain table and/or tableextension objects, but this should be an unnecessary step for designer extensions.
5. Versions:
- Business Central: Version: NA Business Central 16.2 (Platform 16.0.13440.13772 + Application 16.2.13779.0)
alternately, it would be great if there were a command switch in Export-NavData to specify if unpublished extension data should be included in the .navdata export. I think that is a safer option than Sync-NAVApp -mode clean (we may want to retain that data in the source database being exported)
Hi @atoader, any news on this issue?
Unfortunately, we have not been able to address this. We are trying to achieve a balance between building features such as report extensions and addressing the bugs reported by partners, but this means that some issues will be in our backlog for longer. We are working on providing more visibility into how we triage and prioritize issues so that it becomes easier for you to predict when an issue will be solved.
2023 - still an issue :/
Still an issue in BC20. When using multitenancy, a global app wil be placed in these tables in each tenant database when uninstalled and unpublished. Problems occur when someone accidentally publishes a debug app in a tenant database instead of running it without publishing. So we now run this script periodically on each tenant database:
delete from [dbo].[$ndo$navappschematracking] where exists(select * from [dbo].[$ndo$navappuninstalledapp] uninst where [dbo].[$ndo$navappschematracking].appid = uninst.appid)
delete from [dbo].[$ndo$navappuninstalledapp]
@RichardJansen1 I tried your script and i was able to use import-navdata successfully. But when I tried to update an app I got different errors. I think the correct way would be to get the app names and ids from the sql tables and then remove alle traces of these apps with Sync-NAVAPP and the mode clean https://learn.microsoft.com/en-us/powershell/module/microsoft.dynamics.nav.apps.management/sync-navapp?view=businesscentral-ps-24#-mode