/
How to Reference Constant (Static) Member in Groovy Library

How to Reference Constant (Static) Member in Groovy Library

Between Elements of the Same Logic

In one and the same logic, e.g., pricing logic, you can refer to a constant (e.g., parameter name) in previous elements like this:

  • Assume there is an element Params defined as:

    PARAM_PE = "PE" PARAM_MARGIN = "Margin"
  • Further down in the logic, in another element, those constants are looked up like this:

    api.vLookup( Params.PARAM_PE, ...)

This works since the static strings defined in the Params element are accessible from subsequent elements in the same logic.

Between Elements of Different Logics

However, if element Params was defined in a Groovy library – not an unusual use case if the parameter names are to be shared across multiple logics – then the above scheme no longer works.

There is, however, a way to make it work.  Say you define a Groovy library named 'PO'.  Within that library you define a Params element, but this time:

  • You define the static parameter names as:

    @Field PARAM_PE = "PE" @Field PARAM_MARGIN = "Margin"
  • Then you can refer to those parameter names in ordinary logics with:

Related content

Custom REST API Service Using Logics
Custom REST API Service Using Logics
Read with this
Injected Variables & Passing Between Libs / Elements
Injected Variables & Passing Between Libs / Elements
More like this
How to Organise SFDC/Unity Header Inputs into Multi-columns
How to Organise SFDC/Unity Header Inputs into Multi-columns
Read with this
Logic Natures and their Binding Variables
Logic Natures and their Binding Variables
More like this
How to Schedule Jobs with Dependencies
How to Schedule Jobs with Dependencies
Read with this
How to Display Various Symbols in Calculation Results Using Unicode
How to Display Various Symbols in Calculation Results Using Unicode
Read with this

Found an issue in documentation? Write to us.