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

Set-BcContainerFeatureKeys is not working #3609

Open
MaxFalcone opened this issue Aug 12, 2024 · 5 comments · May be fixed by #3696
Open

Set-BcContainerFeatureKeys is not working #3609

MaxFalcone opened this issue Aug 12, 2024 · 5 comments · May be fixed by #3696
Assignees
Labels

Comments

@MaxFalcone
Copy link

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
image

Here is the Feature Management list. Feature (1) I've just enabled, feature (2) is not enabled but present in the list.
image

Here is the content of Tenant Feature Key table in the database. Feature (1) is present and enabled. Feature (2) is not present.
image

Additional context
BCContainerHelper version 6.0.19

@freddydk
Copy link
Contributor

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?

@MaxFalcone
Copy link
Author

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.

@MaxFalcone
Copy link
Author

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;

}

@KM-JAD
Copy link
Contributor

KM-JAD commented Oct 2, 2024

Hi, missing record creation is solved (#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 #3696 is confirmed)

@freddydk
Copy link
Contributor

@KM-JAD added a few comments to your PR - will review again once fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants