Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Let's assume you want to show the customerId value in the outputs. 

If you used just api.customerGroupEntry(), then the result in UI would be shown as e.g. "CG['customerId' = '60838']".

The correct procedure to display the value '60838' is:

  • Use api.getElement("CustomerGroup").customerFieldValue, depending on what is in the CustomerGroup element.
  • First define the CustomerGroup element, visibility set to 'Never':

    CustomerGroup
    api.customerGroupEntry()
  • Then in any other element doing the calculations, use a syntax check.
    Also, set the visibility of this element to 'QuoteConfigurator' at least.

    SomeOtherElement
    if (api.isSyntaxCheck()) return //as the first line
    if (api.getElement("CustomerGroup").customerFieldName == "customerId") {
      return api.getElement("CustomerGroup").customerFieldValue
    }

About Syntax Check

It is used in two use cases:

  1. Anytime you save a formula, it checks whether the Groovy code is well formed and that the code does some additional mocking of dependencies of the current element (it usually tries to add a neutral element of the type but if it cannot infer the type, it will assume the BigDecimal type). 
    So in this case, the syntax checker is unable to infer the return type of the expression api.getElement("CG") and will decide to put there a new BigDecimal(1).

  2. Usually any logic is run twice. In the first run, it just needs to see all calls to the methods which define input params (and so the isSyntaxCheck is set to true). Otherwise it is a normal logic run and this variable is set to false. The first run is really needed for the system to know what inputs the logic will generate.

For more details on isSyntaxCheck see Miscellaneous Functions.

  • No labels