Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Procedure ReinstallExtension to trigger Install Code from AL #1657

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,52 @@ codeunit 2500 "Extension Installation Impl"

exit(Result = PolicyToTestFor);
end;

procedure ReinstallExtension(PackageId: Guid; lcid: Integer; IsUIEnabled: Boolean): Boolean
var
DependentModules: List of [ModuleInfo];
DependentModule: ModuleInfo;
Success: Boolean;
begin
Success := true;
DependentModules := GetDependentModulesForExtensionToReinstall(PackageId);

if not UninstallExtension(PackageId, IsUIEnabled) then
Success := false;

if not InstallExtension(PackageId, lcid, IsUIEnabled) then
Success := false;

foreach DependentModule in DependentModules do
if not InstallExtension(DependentModule.PackageId, lcid, IsUIEnabled) then
Success := false;

exit(Success);
end;

local procedure GetDependentModulesForExtensionToReinstall(PackageId: Guid): List of [ModuleInfo]
var
DependencyApp: Record "NAV App Installed App";
NAVAppInstalledApp: Record "NAV App Installed App";
InstalledModuleDependencies: List of [ModuleDependencyInfo];
DependentModules: List of [ModuleInfo];
InstalledModuleDependency: ModuleDependencyInfo;
InstalledModule: ModuleInfo;
begin
if NAVAppInstalledApp.FindSet() then
repeat
NavApp.GetModuleInfo(NAVAppInstalledApp."App ID", InstalledModule);
InstalledModuleDependencies := InstalledModule.Dependencies();
foreach InstalledModuleDependency in InstalledModuleDependencies do begin
DependencyApp.Get(InstalledModuleDependency.Id);
if DependencyApp."Package ID" = PackageId then begin
if not DependentModules.Contains(InstalledModule) then
DependentModules.Add(InstalledModule);
end;
end;
until NAVAppInstalledApp.Next() = 0;
exit(DependentModules);
end;

}

Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,18 @@ codeunit 2504 "Extension Management"
begin
ExtensionOperationImpl.GetDeploymentDetailedStatusMessageAsStream(OperationId, OutStream);
end;

/// <summary>
/// ReInstalls an extension.
/// Uninstalls the extension and all dependent extensions and then installs it again.
/// </summary>
/// <param name="PackageId">The ID of the extension package.</param>
/// <param name="lcid">The Locale Identifier.</param>
/// <param name="IsUIEnabled">Indicates if the reinstall operation is invoked through the UI.</param>
/// <returns></returns>
procedure ReinstallExtension(PackageId: Guid; lcid: Integer; IsUIEnabled: Boolean): Boolean
begin
exit(ExtensionOperationImpl.ReinstallExtension(PackageId, lcid, IsUIEnabled));
end;
}

Loading