To Enable a DAC Extension Conditionally (IsActive)

You need to disable a DAC extension when it is not required by the system logic (for example, when the feature that uses the extension is not enabled) because when an extension is constantly active, it can impair the system's performance.

To disable or enable a DAC extension depending on a condition, you need to implement the public static bool IsActive method in the extension. The following code shows an example of the implementation of the IsActive method.

public static bool IsActive()
{
    return PXAccess.FeatureInstalled<FeaturesSet.rutRotDeduction>();
}

In the code above, the extension is enabled when the rutRotDeduction feature is enabled.

If the IsActive method returns false for a DAC extension, this extension is not loaded. This means the following:

  • Fields defined in the DAC extension that should be visible on forms will be automatically hidden.
  • If a field is used in a generic inquiry as a column in the results grid or in a report as a text box, the field is also hidden. If the field is used in a configuration of a generic inquiry or a report, an error is thrown indicating that the field is not found.
  • Database fields defined in the DAC extension will not be in SQL queries generated by the system. So if you have a BQL query that explicitly adds OrderBy, GroupBy, Where, and possibly other statements to such a field, an error is thrown indicating that the field is not found.
  • In a graph or a graph extension, if an event handler is declared for a field of a disabled DAC extension, the event handler is not executed.