Rule Builder Node

      Rule Builder Node


        Article summary

        Rule Builder Node

        The rule builder node enables the creation of complex multi-step rules using a simple codeless interface. The output of the node will vary depending on the specific rule configured.

        Use the rule builder node to:

        • Create logic using IF, AND, OR, ELSE, ELSEIF, and THEN conditions,
        • Produce nested logic,
        • Act on fields, including field modifiers such as [[varName(-1)]],
        • Lookup values from custom tables,
        • Apply operators (=,<,>, ≤, ≥, ≠, between, and not between),
        • and Output multiple variables.

        The node produces a sample JavaScript so that advanced users can verify the logic. 

        Adding a Rule Builder node to your workflow

        1. First, select your desired solution and navigate to Rayven Workflow.
        2. Select ‘Functions’ from the left-hand panel.
        3. Find the Rule Builder node and drag it onto the canvas.
        4. Connect the Rule Builder node to your desired input node.
        5. Double click on the Rule Builder node to open its configuration window.

        Configuring your Rule Builder Node

        1. Give your node a Name. Choose something simple that clearly explains its purpose. You must pick a name that has three or more characters.
        2. Decide what you want your node to do if an error takes place: 
          • Continue - Add Error to JSON: The error will appear in the JSON payload.
          • Continue - Ignore Error: The error won't appear in the JSON payload.
          • Stop - Log Error: The calculation and data flow will pause, and the node will flag the error.
        3. When the node encounters a coding error, the default action is to add the error text to the JSON. If you select 'Output Zero if Value Not Found' a 0 will appear in the output field instead. 
        4. Use 'Add Operator' to add new fields and operators to your rule. This function is optional but can be useful when creating complex rules. 

        Building a rule

        1. All rules start with an IF statement. Begin by adding an operand and then selecting an operator (=, <, >, ≤, ≥, ≠, between, and not between). A field will then appear for you to enter your second operand. If you choose 'between' or 'not between', the lower and upper bounding operands will each have a field. 
        2. Between and Not Between can be defined exclusively or inclusively as follows:
          • Exclusive Between: the variable is within an interval that does not include the endpoints. For example 10 < a < 100.
          • Inclusive Between: the variable is within an interval that does include the endpoints. For example 10 <= a <= 100.
          • Exclusive Not Between: the variable is outside of an interval that does include the endpoints. For example a < 10 OR a > 100.
          • Inclusive Not Between: the variable is outside of an interval that does not include the endpoints. For example a <= 10 OR a >= 100.
        3. To add a nested operation, press the blue + to the right of the statement. A new statement will appear, indented from the one above. The blue + indents from the line it is on. 
        4. As you create your rule, JavaScript code will begin to form in the grey box at the bottom of the rule builder. The button 'Preview JS Code' will refresh this code. This code is an aid and verification tool to help you check the logic.

        1. To the left of each row is a blue box with handles. If you want to re-sequence your operations, click the handles and drag.
        2. This handle acts on nested operations: in the example below, you wouldn't need to worry about accidentally placing the AND statement above the IF statement. 
        3. In this way, you can build complex business rules.

        Formatting guidelines

        • When adding fields, use the notation [[varName]],
        • Enclose the text in single quotes, e.g. 'Text',
        • When using multiple assignments, use multiple THEN statements (as the AND statement is a logical operator). 


        See Also: JavaScript Node
        As of Release: 28.10.2021