Skip to content

Set-BcContainerFeatureKeys is not working #3609

Open
@MaxFalcone

Description

@MaxFalcone

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

Activity

freddydk

freddydk commented on Aug 30, 2024

@freddydk
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

MaxFalcone commented on Aug 30, 2024

@MaxFalcone
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

MaxFalcone commented on Aug 30, 2024

@MaxFalcone
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

KM-JAD commented on Oct 2, 2024

@KM-JAD
Contributor

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

freddydk commented on Oct 10, 2024

@freddydk
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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @freddydk@MaxFalcone@KM-JAD

    Issue actions

      Set-BcContainerFeatureKeys is not working · Issue #3609 · microsoft/navcontainerhelper