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 authored Sep 10, 2024
1 parent 782de91 commit 8fe01a0
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 @@ -53,7 +53,8 @@ codeunit 2500 "Extension Installation Impl"
exit(not NAVAppInstalledApp.IsEmpty());
end;

procedure IsInstalledByAppId(AppID: Guid): Boolean

procedure IsInstalledByAppId(AppId: Guid): Boolean
var
[SecurityFiltering(SecurityFilter::Ignored)]
NAVAppInstalledApp: Record "NAV App Installed App";
Expand Down Expand Up @@ -209,15 +210,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 @@ -228,7 +229,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 @@ -241,6 +241,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 8fe01a0

Please sign in to comment.