Skip to content

Commit

Permalink
Use AppId function to delete orphaned extension data AB#534788 (#1976)
Browse files Browse the repository at this point in the history
Problem: Before apps not installed since 14.x might be missing a package
ID. So we are unable to delete them by packageID

Fix: Delete by AppId

Fixes:
[AB#534788](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/534788)
  • Loading branch information
ehenriksen9 committed Nov 12, 2024
1 parent d9b5301 commit 006c004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ codeunit 2500 "Extension Installation Impl"
exit(not NAVAppInstalledApp.IsEmpty());
end;

procedure IsInstalledByAppId(AppID: Guid): Boolean

procedure IsInstalledByAppId(AppId: Guid): Boolean
var
NAVAppInstalledApp: Record "NAV App Installed App";
begin
Expand Down Expand Up @@ -207,15 +208,15 @@ codeunit 2500 "Extension Installation Impl"
exit(UninstallExtensionSilently(PackageID, ClearSchema, ClearSchema));
end;

procedure DeleteOrphanData(PackageID: Guid; ExtensionName: Text): Boolean
procedure DeleteOrphanData(AppId: Guid; ExtensionName: Text): Boolean
var
ConfirmManagement: Codeunit "Confirm Management";
begin
CheckPermissions();

if not ConfirmManagement.GetResponse(StrSubstNo(ClearExtensionSchemaOrphanMsg, ExtensionName), false) then exit(false);

exit(UninstallExtensionSilently(PackageID, false, true));
exit(UninstallExtensionSilentlyByAppId(AppId, false, true));
end;

procedure RunOrphanDeletion(OrphanedApplication: Record "Extension Database Snapshot"): Boolean
Expand All @@ -226,7 +227,6 @@ codeunit 2500 "Extension Installation Impl"
exit(OrphanedExtensionDetails.RunModal() = Action::OK);
end;


local procedure UninstallExtensionSilently(PackageID: Guid; ClearData: Boolean; ClearSchema: Boolean): Boolean
begin
CheckPermissions();
Expand All @@ -239,6 +239,18 @@ codeunit 2500 "Extension Installation Impl"
exit(true);
end;

local procedure UninstallExtensionSilentlyByAppId(AppId: Guid; ClearData: Boolean; ClearSchema: Boolean): Boolean
begin
CheckPermissions();
AssertIsInitialized();
DotNetNavAppALInstaller.ALUninstallNavAppByAppId(AppId, ClearData, ClearSchema);

if IsInstalledByAppId(AppId) then
exit(false);

exit(true);
end;

procedure UninstallExtensionWithConfirmDialog(PackageId: Guid; ClearData: Boolean; ClearSchema: Boolean): Boolean
var
PublishedApplication: Record "Published Application";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ page 2513 "Extn. Orphaned App Details"

trigger OnAction()
begin
ExtensionInstallationImpl.DeleteOrphanData(Rec."Package Id", Rec."Name");
ExtensionInstallationImpl.DeleteOrphanData(Rec."App Id", Rec."Name");
CurrPage.Close();
end;
}
Expand Down

0 comments on commit 006c004

Please sign in to comment.