Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

...

  • Code Block

...

  • languagegroovy

...

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

...

  • Code Block

...

  • languagegroovy

...

  • 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.

...

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:

     

    paste-code-macro
    languagegroovy
    titleDefinition of constants in Groovy Library code
    @Field PARAM@Field PARAM_PE = "PE"
    @Field @Field PARAMPARAM_MARGIN = "Margin"
  • Then you can refer to those parameter names in ordinary logics with:

    paste-code-macro
    languagegroovytitleReferencing Groovy Library constants from other elements
    libs.PO.Params.PARAM_PE
Page Properties
hiddentrue

Author

Contributors
limit1
showLastTimetrue
reversetrue
orderupdate