Versions Compared

Key

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

...

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

...

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

    Code Block
    titleCustomerGroup
    api.customerGroupEntry()


  • Then in any other element doing the calculations, use a syntax check.
    Also, set the visibility Display Mode of this element to 'QuoteConfiguratorQuoting' at least.

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


...

  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.

...