- 11 Jul 2022
- 2 Minutes to read
- Print
- DarkLight
Creating an Expression Rule
- Updated on 11 Jul 2022
- 2 Minutes to read
- Print
- DarkLight
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.
- In a Designer Project, click CREATE RULE. Click CREATE, select Expression, and click Expression.
- In the Expression window, enter 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. - Back in the Designer Project, select CREATE FLOW on the Global Action Bar.
- Choose the Flow tile and provide a name, then select CREATE to open the Flow Designer.
- 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. - 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.
- Select the Braking Distance step and expand the INPUTS section.
- Select the Pick button under Distance and choose the Distance output of the Form.
- Select the Pick button under Speed and choose the Speed output of the Form.
- 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
- Click Debug on the top panel. Click START DEBUGGING.
- 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.
- 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.
- Run the debugger again with the same speed but a longer distance. The Form with "Successful Breaking" appears as a result.