Table of Contents

KVSCOREFeature

Summary: Feature Management module. Use this module to manage changing processes and to control whether the old way should still be used or the new one. If the old process flow has been removed from the product, the feature can be hidden or removed.

Procedures

Get(Code[20]) : Codeunit

Summary: Retrieves a feature based on the provided code. This results in a runtime error if the feature does not exist.

procedure Get(Code: Code[20]): Codeunit

Parameters:

  • Code: The code of the feature to retrieve.

Returns: Returns the current instance of the KVSCOREFeature codeunit.

Example:

Feature := Feature.Get(FeatureCodeTok)

Exists(Code[20]) : Boolean

Summary: Checks if a feature with the specified code exists.

procedure Exists(Code: Code[20]): Boolean

Parameters:

  • Code: The code of the feature to check for existence.

Returns: Returns true if the feature exists; otherwise, false.

Example:

if Feature.Exists(FeatureCodeTok) then
  // Do Something

IsEnabled() : Boolean

Summary: Determines whether the feature is enabled.

procedure IsEnabled(): Boolean

Returns: True if the feature is enabled; otherwise, false.

Example:

if Feature.Get(FeatureCodeTok).IsEnabled() then
  // Do Something

Add(Code[20], Text[10], Boolean, Boolean) : Codeunit

OBSOLETE

This Element will be removed or changed with a future Version of the App.

Summary: Adds a new feature to the feature management system. if a new feature is added, OnGetName and OnGetDescription events should be subscribed to provide the displayname and description of the feature.

[Obsolete('Use procedure Add(Code: Code[20]; MandatoryByVersion: Text[10]; NewEnvOrCompMandatoryByVersion: Text[10]; Enabled: Boolean; IsOneWay: Boolean) instead.', '27.3')]
procedure Add(Code: Code[20]; MandatoryByVersion: Text[10]; Enabled: Boolean; IsOneWay: Boolean): Codeunit

Parameters:

  • Code: The unique code identifier for the feature.
  • MandatoryByVersion: The version by which the feature becomes mandatory. Must be in format "xx.x" (Regex: \d{2}.\d)
  • Enabled: Indicates whether the feature is enabled. Attention: if the feature is initialized as enabled, no feature activation is called initially
  • IsOneWay: Indicates whether the feature is a one-way feature (cannot be disabled once enabled).

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Add(FeatureCodeTok, '25.3', false, false);

Add(Code[20], Text[10], Text[10], Boolean, Boolean) : Codeunit

Summary: Adds a new feature to the feature management system. if a new feature is added, OnGetName and OnGetDescription events should be subscribed to provide the displayname and description of the feature.

procedure Add(Code: Code[20]; MandatoryByVersion: Text[10]; NewEnvOrCompMandatoryByVersion: Text[10]; Enabled: Boolean; IsOneWay: Boolean): Codeunit

Parameters:

  • Code: The unique code identifier for the feature.
  • MandatoryByVersion: The version by which the feature becomes mandatory. Must be in format "xx.x" (Regex: \d{2}.\d)
  • NewEnvOrCompMandatoryByVersion: The version by which the feature becomes mandatory for newly created environments or companies. Must be in format "xx.x" (Regex: \d{2}.\d)
  • Enabled: Indicates whether the feature is enabled. Attention: if the feature is initialized as enabled, no feature activation is called initially
  • IsOneWay: Indicates whether the feature is a one-way feature (cannot be disabled once enabled).

Returns: Returns the KVSCOREFeature codeunit.

Example:

F
            Feature.Add(FeatureCodeTok, '27.4', '27.1', false, false);
            

Add(Code[20], Version, Boolean, Boolean) : Codeunit

OBSOLETE

This Element will be removed or changed with a future Version of the App.

Summary: Adds a new feature to the feature management system. if a new feature is added, OnGetName and OnGetDescription events should be subscribed to provide the displayname and description of the feature.

[Obsolete('Use procedure Add(Code: Code[20]; MandatoryByVersion: Version; NewEnvOrCompMandatoryByVersion: Version; Enabled: Boolean; IsOneWay: Boolean) instead.', '27.3')]
procedure Add(Code: Code[20]; MandatoryByVersion: Version; Enabled: Boolean; IsOneWay: Boolean): Codeunit

Parameters:

  • Code: The unique code identifier for the feature.
  • MandatoryByVersion: The version by which the feature becomes mandatory.
  • Enabled: Indicates whether the feature is enabled. Attention: if the feature is initialized as enabled, no feature activation is called initially
  • IsOneWay: Indicates whether the feature is a one-way feature (cannot be disabled once enabled).

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Add(FeatureCodeTok, Version.Create(25, 3), false, false);

Add(Code[20], Version, Version, Boolean, Boolean) : Codeunit

Summary: Adds a new feature to the feature management system. if a new feature is added, OnGetName and OnGetDescription events should be subscribed to provide the displayname and description of the feature.

procedure Add(Code: Code[20]; MandatoryByVersion: Version; NewEnvOrCompMandatoryByVersion: Version; Enabled: Boolean; IsOneWay: Boolean): Codeunit

Parameters:

  • Code: The unique code identifier for the feature.
  • MandatoryByVersion: The version by which the feature becomes mandatory.
  • NewEnvOrCompMandatoryByVersion: The version by which the feature becomes mandatory for newly created environments or companies.
  • Enabled: Indicates whether the feature is enabled. Attention: if the feature is initialized as enabled, no feature activation is called initially
  • IsOneWay: Indicates whether the feature is a one-way feature (cannot be disabled once enabled).

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Add(FeatureCodeTok, Version.Create(27, 4), Version.Create(27, 1), false, false);

SetMandatoryByVersion(Version) : Codeunit

Summary: Sets the mandatory version for the feature using a Version type.

procedure SetMandatoryByVersion(MandatoryByVersion: Version): Codeunit

Parameters:

  • MandatoryByVersion: The version by which the feature becomes mandatory. Although a build and revision number can also be passed here, only major and minor are used.

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Get(FeatureCodeTok).SetMandatoryByVersion(Version.Create(25, 3));

SetMandatoryByVersion(Text[10]) : Codeunit

Summary: Sets the mandatory version for the feature using a text representation.

procedure SetMandatoryByVersion(MandatoryByVersion: Text[10]): Codeunit

Parameters:

  • MandatoryByVersion: The version by which the feature becomes mandatory. Must be in format "xx.x" (Regex: \d{2}.\d)

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Get(FeatureCodeTok).SetMandatoryByVersion('25.3');

SetNewEnvOrCompMandatoryByVersion(Version) : Codeunit

Summary: Sets the mandatory version for a newly created environment or new company for the feature using a Version type.

procedure SetNewEnvOrCompMandatoryByVersion(NewEnvOrCompMandatoryByVersion: Version): Codeunit

Parameters:

  • NewEnvOrCompMandatoryByVersion: The version by which the feature becomes mandatory for a newly created environment or company. Although a build and revision number can also be passed here, only major and minor are used.

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Get(FeatureCodeTok).SetNewEnvOrCompMandatoryByVersion(Version.Create(28, 0));

SetNewEnvOrCompMandatoryByVersion(Text[10]) : Codeunit

Summary: Sets the mandatory version for a newly created environment or new company for the feature using a text representation.

procedure SetNewEnvOrCompMandatoryByVersion(NewEnvOrCompMandatoryByVersion: Text[10]): Codeunit

Parameters:

  • NewEnvOrCompMandatoryByVersion: The version by which the feature becomes mandatory for a newly created environment or company. Must be in format "xx.x" (Regex: \d{2}.\d)

Returns: Returns the KVSCOREFeature codeunit.

Example:

Feature.Get(FeatureCodeTok).SetNewEnvOrCompMandatoryByVersion('28.0');

Remove() :

Summary: Removes the specified feature.

procedure Remove(): 

Example:

if Feature.Exists(FeatureCodeTok) then
  Feature.Get(FeatureCodeTok).Remove();

Remarks: This procedure handles the removal of a feature from the system. Ensure that the feature exists before calling this procedure.

Enable() : Codeunit

Summary: Enables the feature.

procedure Enable(): Codeunit

Returns: An instance of the KVSCOREFeature codeunit.

Example:

trigger OnUpgradePerCompany()
begin
  Feature.Get(FeatureCodeTok).Enable();
end;

Disable() : Codeunit

Summary: Disables the feature.

procedure Disable(): Codeunit

Returns: An instance of the KVSCOREFeature codeunit.

Example:

Feature.Get(FeatureCodeTok).Disable();

Finalize() : Codeunit

Summary: Finalizes the feature management process. This means that the feature will be activated if not already done and set to one way so that it cannot be deactivated again

procedure Finalize(): Codeunit

Returns: Returns An instance of the KVSCOREFeature codeunit.

Example:

trigger OnUpgradePerCompany()
begin
  Feature.Get(FeatureCodeTok).Finalize();
end;

Hide() : Codeunit

Summary: Hides the feature. Hidden features are no longer displayed in feature management, but it is still possible to query whether the feature is active. Before a feature is removed, it should first be hidden for a while to give dependent apps a little more time to take the necessary steps. Please note: once a feature has been hidden, it can only be made visible again by creating it again.

procedure Hide(): Codeunit

Returns: An instance of the KVSCOREFeature codeunit.

Example:

trigger OnUpgradePerCompany()
begin
  Feature.Get(FeatureCodeTok).Hide();
end;

DisableGui() :

Summary: Disables the GUI for the feature management process. Use this to hide confirmation dialogs during company initialization.

procedure DisableGui(): 

Events

OnEnableFeature(Code[20]) :

Summary: Event handler for enabling a feature.

[IntegrationEvent(false, false)]
local procedure OnEnableFeature(Code: Code[20]): 

Parameters:

  • Code: The code of the feature to be enabled.

Example:

[EventSubscriber(ObjectType::Codeunit, Codeunit::KVSCOREFeature, OnEnableFeature, '', false, false)]
local procedure EnableFeature(Code: Code[20])
begin
  if Code <> FeatureCodeTok then
    exit;
  // Upgrade Data
end;

OnAfterEnableFeature(Code[20]) :

Summary: Event handler after a feature has been enabled and the Feature record has been updated.

[IntegrationEvent(false, false)]
local procedure OnAfterEnableFeature(Code: Code[20]): 

Parameters:

  • Code: The code of the feature that has been enabled.

Example:

[EventSubscriber(ObjectType::Codeunit, Codeunit::KVSCOREFeature, OnAfterEnableFeature, '', false, false)]
local procedure AfterEnableFeature(Code: Code[20])
begin
  if Code <> FeatureCodeTok then
    exit;
  // Logic after enabling the feature
end;

OnDisableFeature(Code[20]) :

Summary: Event handler for disabling a feature.

[IntegrationEvent(false, false)]
local procedure OnDisableFeature(Code: Code[20]): 

Parameters:

  • Code: The code of the feature to be enabled.

Example:

[EventSubscriber(ObjectType::Codeunit, Codeunit::KVSCOREFeature, OnDisableFeature, '', false, false)]
local procedure DisableFeature(Code: Code[20])
begin
  if Code <> FeatureCodeTok then
    exit;
  // Revert Data
end;

OnAfterDisableFeature(Code[20]) :

Summary: Event handler after a feature has been disabled and the Feature record has been updated.

[IntegrationEvent(false, false)]
local procedure OnAfterDisableFeature(Code: Code[20]): 

Parameters:

  • Code: The code of the feature that has been disabled.

Example:

[EventSubscriber(ObjectType::Codeunit, Codeunit::KVSCOREFeature, OnAfterDisableFeature, '', false, false)]
local procedure DisableFeature(Code: Code[20])
begin
  if Code <> FeatureCodeTok then
    exit;
  // Logic after disabling the feature
end;

OnGetName(Code[20], Text[100], Boolean) :

Summary: Event handler for retrieving the name of a feature based on its code.

[IntegrationEvent(false, false)]
local procedure OnGetName(Code: Code[20]; var Result: Text[100]; var IsHandled: Boolean): 

Parameters:

  • Code: The code of the feature.
  • Result: The variable to store the resulting name of the feature.
  • IsHandled: Indicates whether the event has been handled.

OnGetDescription(Code[20], Text, Boolean) :

Summary: Event handler for retrieving the description of a feature based on its code.

[IntegrationEvent(false, false)]
local procedure OnGetDescription(Code: Code[20]; var Result: Text; var IsHandled: Boolean): 

Parameters:

  • Code: The code of the feature.
  • Result: The variable to store the resulting description of the feature.
  • IsHandled: Indicates whether the event has been handled.