Versions Compared

Key

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

...

  1. Condition formula, stored in condition property of jsonExt calculationRuleObjectList object, is parsed and evaluated using https://github.com/handsontable/formula-parser. Therefore formulas have to follow the structure defined by this library. Formula evaluation should always return a boolean value:

    1. true if a condition is satisfied

    2. false if else

  2. To use calculation parameter value in a formula, INPUT keyword has to be used in the formula. As the parser parses the formula, INPUT string is replaced with the value of the calculation parameter.

  3. To use object/entity (PHInusree/CDetails/...) in a formula, OBJECT. prefix, followed by object’s/entity’s property name has to be used in the formula. OBJECT. string is reserved only for this purpose. Please note that after OBJECT there is a dot (.).

  4. Object/entity variables/properties can be accessed using dot-notation. If one wants to use value of isDeleted variable/property of an object/entity (PHInusree/CDetails/...) in the formula, he puts OBJECT.isDeleted. What is important is that the string (here: isDeleted) has to match the GQL object's property name. If isdeleted, ISDELETED etc. is used, the solution does not work.

  5. Dot-notation can be used to access nested variables/properties of object's properties. For example if PHInsuree ID is needed in the formula it can be accessed by putting OBJECT.insuree.id in it. There is no depth limit, however, if any property name at any level does not match any name from properties of currently accessed object, the retrieved value will be null. An OBJECT (PHInsuree for example) has to have insuree property, where insuree has to have id property.

  6. If validation fails, Value validation failed error is displayed under the calculation parameter input.

  7. Result of validation can be returned from CalculationInputclass and used to block form submission if setJsonExtValid function is passed as a prop. The function has to accept one argument of type boolean. This argument will be:

    1. true if the condition is satisfied

      1. if > 1 conditions - if all conditions are satisfied

    2. false if the condition is not satisfied

      1. if > 1 conditions - if at least one of the conditions is not satisfied

under the hood

the Dot-notation in the formula is replaced with upper-case string, separated with _, because https://github.com/handsontable/formula-parser formula parser does not allow variables (https://github.com/handsontable/formula-parser#setvariablename-value ) to contain . sign. Therefore OBJECT.insuree.id in the original formula is replaced with INSUREE_ID. As a result a retrieved value (here: id of insuree of PHInsuree) is assigned to a parser variable INSUREE_ID. As the parser parses the formula, INSUREE_ID string is replaced with the retrieved value

...

If validation fails, Value validation failed error is displayed under the calculation parameter input.

...

.

...

true if the condition is satisfied

  1. if > 1 conditions - if all conditions are satisfied

false if the condition is not satisfied

...