Formula Editor: Customization of Option Providers

You can customize the option sets provided by the AddFunctions, AddOperators, and AddStyles attributes by doing one of the following:

  • Defining a custom option provider that inherits from PXFormulaEditor.OptionsProviderAttribute and defining the option set, as described in Formula Editor: Implementation of Custom Option Providers.
  • Defining a custom option provider that inherits from one of the existing attributes and modifying the existing option set. You do this by adding, updating, or deleting options from the set.
    Note: Do not use both the custom option provider and its parent attribute (AddFunctions, AddOperator, or AddStyles) together. This could cause the changes to be applied unpredictably in the child attribute.

    You can use any combination of standard attributes and descendants of PXFormulaEditor.OptionsProviderAttribute together.

    For example, you can use this approach to remove multiple values from the AddStyles attribute, as shown in the following code.

    public class RemoveRedStylesAttribute : OptionsProviderAttribute
    {
        public override void ChangeOptionsSet(PXGraph graph, ISet<FormulaOption> options)
        {
            options.Remove(DefaultFormulaOptions.Styles.Red);
            options.Remove(DefaultFormulaOptions.Styles.Red60);
            options.Remove(DefaultFormulaOptions.Styles.Red40);
            options.Remove(DefaultFormulaOptions.Styles.Red20);
            options.Remove(DefaultFormulaOptions.Styles.Red00);
        }
    }

You can attach a custom option provider in the following places:

  • On the DAC field in the DAC definition.

    We recommend this approach when you write original code and the option set does not depend on the graph logic.

  • On the CacheAttached event handler in the graph code.

    We recommend this approach when you customize existing code and the option set depends on the graph logic.

  • On the DAC extension.

    We recommend this approachwhen the change should be applied to the DAC regardless of where it is used.

The following diagram shows how you should select the approach to define a custom option provider.

Figure 1. Selecting a way to customize an option provider
[1]janice.paganini- Re. the second sentence, the verb form is odd because it sounds like it's asking if you do this on an ongoing basis. Do we mean "Do I need to write a customization?" I'm also not sure if "write" is the best term (versus "develop" or "create"). - The first white rectangle is missing a word. Add "to" after "attach it" ... - In the second rectangle, is the "instead of a standard attribute" phrase describing what the option provider inherits from"? If so, move it before "and" ... If you mean that you attach it to the DAC field instead of *to* a standard attribute, add the word in asterisks to aid understanding. - In the third AND fourth rectangles, we are missing an object after "apply"; please add it.2024/08/1916:54:39-04:00