Set-BcContainerFeatureKeys is not working
Describe the issue
Set-BcContainerFeatureKeys is not enabling feature keys because it tries to update record in Tenant Feature Key table but record is missing initially and only created when you enable feature manually via UI.
Scripts used to create container and cause the issue
Option one. Using featureKeys parameter
New-BcContainer -accept_eula -artifactUrl (Get-BCArtifactUrl -type OnPrem -country w1 -version 24.3) -memoryLimit 16G -includeAL -containerName KZW1 -auth Windows -includeTestToolkit -includeTestLibrariesOnly -shortcuts None `
-featureKeys @{"ExtensibleExchangeRateAdjustment" = "All Users"; "ExtensibleInvoicePostingEngine" = "All Users"}
Option two. Using Set-BcContainerFeatureKeys cmdlet
New-BcContainer -accept_eula -artifactUrl (Get-BCArtifactUrl -type OnPrem -country w1 -version 24.3) -memoryLimit 16G -includeAL -containerName KZW1 -auth Windows -includeTestToolkit -includeTestLibrariesOnly -shortcuts None
Set-BcContainerFeatureKeys -containerName KZW1 -featureKeys @{"ExtensibleInvoicePostingEngine"="1"}
Full output of scripts
Setting feature keys on database: CRONUS
Setting feature key ExtensibleInvoicePostingEngine to 1 - Failure
WARNING: Unable to set feature key ExtensibleInvoicePostingEngine
Screenshots
Here is the Feature Management list. Feature (1) I've just enabled, feature (2) is not enabled but present in the list.
Here is the content of Tenant Feature Key table in the database. Feature (1) is present and enabled. Feature (2) is not present.
Additional context BCContainerHelper version 6.0.19
So, you are saying that if you run the Set-BcContainerFeatureKeys after you went into the UI - then the key is there and it works?
No. Set-BcContainerFeatureKeys won't work at all. It tries to update record in the table, but record is not present there initially. It will be created only when you toggle feature through UI.
In case someone is looking for workaround. For now I'm just enabling required features through the installer codeunit of my test app.
codeunit 50000 Installer
{
Subtype = Install;
trigger OnInstallAppPerDatabase();
begin
EnableFeatureKeys();
end;
local procedure EnableFeatureKeys()
var
ExtensibleExchangeRateAdjustmentLbl: Label 'ExtensibleExchangeRateAdjustment', Locked = true;
ExtensibleInvoicePostingEngineLbl: Label 'ExtensibleInvoicePostingEngine', Locked = true;
begin
EnableFeatureKey(ExtensibleExchangeRateAdjustmentLbl);
EnableFeatureKey(ExtensibleInvoicePostingEngineLbl);
end;
local procedure EnableFeatureKey(FeatureKeyName: Text)
var
FeatureKey: Record "Feature Key";
FeatureManagementFacade: Codeunit "Feature Management Facade";
begin
if FeatureKey.Get(FeatureKeyName) then
if FeatureKey.Enabled = FeatureKey.Enabled::None then begin
FeatureKey.Enabled := FeatureKey.Enabled::"All Users";
FeatureKey.Modify();
FeatureManagementFacade.AfterValidateEnabled(FeatureKey);
end;
end;
}
Hi, missing record creation is solved (https://github.com/microsoft/navcontainerhelper/pull/3658). The problem is that content of "virtual" table behind page "Feature Management" is updated dynamically from two tables during page opening:
- "Tenant Feature Key" - general enablement of feature
- "Feature Data Update Status$63ca2fa4-4f03-4f2b-a480-172fef340d3f" - enabling for particular Company So, each feature (and related AL code) is activated in particular company just solely in case that both records are set properly.
(second table will be updated after https://github.com/microsoft/navcontainerhelper/pull/3696 is confirmed)
@KM-JAD added a few comments to your PR - will review again once fixed
There has been no recent activity on this issue. Please re-open or create a new issue, if needed.