Skip to content

Commit

Permalink
[25.x] Use AppId function to delete orphaned extension data AB#557275 (
Browse files Browse the repository at this point in the history
…#2343)

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)

<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary <!-- Provide a general summary of your changes -->

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes #

Backport of #1976
  • Loading branch information
ehenriksen9 authored Nov 15, 2024
1 parent 1e9b3b5 commit 1fd1ac5
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 1fd1ac5

Please sign in to comment.