Creating an Expression Rule
  • 11 Jul 2022
  • 2 Minutes to read
  • Dark
    Light

Creating an Expression Rule

  • Dark
    Light

Overview

An Expression Rule allows a user to create a Defined Expression Entity that can be used as a step for a Flow with a Boolean outcome. To create one, click on CREATE RULE in the Designer Project and pick Create Expression sub-menu. After the expression is created, locate it in the Flow designer Toolbox under Integration > Expressions > [UserDefinedCategory] > [UserDefinedNameOfExpression].

Example

In this example, an Expression Rule will utilize a formula to calculate a vehicle's braking distance to the object. Then, a Flow will ask a user for the current speed and distance to the stop point. Next, it will tell the user if this distance is enough for the current speed to stop before the desired stop point. Below is a downloadable example .zip file that can be imported into Decisions. 



  1. In a Designer Project, click CREATE RULE. Click CREATE, select Expression, and click Expression.
  2. In the Expression windowenter an Expression Name to be the name of the step in the Flow Designer.

    Enter an Expression and place variable values in square braces.

    Enter a Step Category that will define the subcategory that can be found under the Expressions category. Click SAVE to save and close the window.
  3. Back in the Designer Project, select CREATE FLOW on the Global Action Bar.
  4. Choose the Flow tile and provide a name, then select CREATE to open the Flow Designer.
  5. In the Flow Designer, add a Show Form step from the FAVORITES section of the Toolbox between the Start and End steps. Create a Form.

    This example uses a Form designed with two number boxes to capture the distance and speed as values of the Double data type.


  6. After the Show Form step is added and the Form is configured, add the Expression Rule Step [Braking Distance] from Integration > Expressions > Auto category in the Toolbox.
  7. Select the Braking Distance step and expand the INPUTS section.
  8. Select the Pick button under Distance and choose the Distance output of the Form.
  9. Select the Pick button under Speed and choose the Speed output of the Form.
  10. This example uses two more simple Forms for the True and False path of the Expression Rule. One to indicate the brake distance is successful and the other to indicate a potential wreck.


Debug

  1. Click Debug on the top panel. Click START DEBUGGING.
  2. When the debugger runs, enter "60" as the distance and "40" as the speed and click Calculate. The Form with "Possible Wreck" will be displayed to the user.
  3. Select the Braking Distance step and choose Execution 1, and select View Input/Output Data from the menu to see how the inputs are evaluated.
  4. Run the debugger again with the same speed but a longer distance. The Form with "Successful Breaking" appears as a result.


For further information on Rules, visit the Decisions Forum.

Was this article helpful?