Multiple Outcomes From Truth TableLast Updated: 07/26/2016 Introduced in Verision: 2.0 |
This tutorial demonstrates how to use Multiple Outcomes from the Truth Table. This feature is implemented in Decisions 3.2. Data Return Rule (Multiple) option is a new Truth Table Type that can be set in the Output section in Truth Table Configurations.
Example:
In this example we will create a Flow with a Truth Table that has Multiple Outcomes. This Truth Table will check the Age of the customer that is renting a car. If customer is under 16, he or she should not be able to rent a car. If he or she is over 16 but younger 25, Young Driver Fee should be applied. Finally, Truth Table should output if customer is able to rent a car, if Young Driver fee should be applied, and estimated daily rental cost.
We begin in the Designer Folder with clicking Create Rule > Create Truth Table option from Folder Actions Panel.
Then, we Name our Truth Table and click Create to proceed to the Rule Designer.
In the Rule Designer we locate Output section in the Truth Table Configurations. We select Data Return (Multiple) from the Truth Table Type dropdown menu.
Next, we click Add New link to add Rule Input Data.
In the Add Rule Input Data window we Name our Input, define its Type and click Ok to save and close this pop-up window.
Then, we click Add New link in the Output section to add Output Data.
In the Add Output Data window we add CanRent Boolean data and click Ok to save and continue…
In the same manner we add IsYoungDriver Boolean Output Data. For this data we check Can Be Null checkbox. Click Ok to save.
Finally, we add CostPerDay Int32 Output Data, and check Can Be Null checkbox. Then, we click Ok.
Back in the Output Configurations for the Truth Table we locate Default Output section and select Constant Mapping type for CanRent Output Data.
We leave Value checkbox for the CanRent Output Data unchecked. In this case default output for this Data should be False.
Next, we click [no anchor data] link on the Truth Table to define Rule Phrase for our Truth Table.
We select Age and click Close…
Then, we click [n/a] link next to the anchor Data we just selected to add a verb to our Rule Phrase.
In the resulting pop-up window we expand Number Rules category and select Between verb. Then, Close this pop-up window.
Next, we click [ignored] link on the first row of our Truth Table, and Inputs window pops up. Here, we can define Inputs for our Truth Table condition.
We define inputs between 0 and 16 including equals and click Close.
Then, we click on the Result link for this row and Outputs window pops up. We define CanRent Output Data as False and click Close.
Then, we click add row link to add another definition for our Truth Table Phrase.
In the resulting pop-up window we are able to define Inputs and Outputs for the new Row.
We define Inputs and Outputs for our second row as following… If the Customer is Between 17 and 24 (including equals), he or she CanRent the car, Young Driver Fee should be applied, and CostPerDay is 45. Click Close to save this row definition.
Next, we click add row again. Row definition window pops up… Mention, that in previous step we were able to define only Constant Values for Inputs and Outputs. But, what if we want to select a different Mapping Type for the Inputs and Outputs in the Row Definition for our Truth Table? We check Show Mappings checkbox for this purpose…
As a result – Mappings for all Inputs and Outputs in our row are available. For this example we keep all Mappings Constant. We define this last row in our Truth Table as following… If the Customer is over 25 (including equals), he or she CanRent a car, Young Driver Fee should not be applied, and CostPerDay should be 35. Then, we click Close to save and close row definition window.
Our Truth Table Design is completed now. We can save and close Rule Designer.
Back in the Designer Folder we are going to create a Flow to test our Truth Table. We click Create Flow on the Folder Actions Panel.
Then, we Name the Flow and click Create to proceed to the Flow Designer.
In the Flow Designer we add Show Form step from the Favorite Steps in the Flow Designer Wizard.
In the resulting pop-up window we Name our Form and click Create to proceed to the Form Designer.
Design for this Form is simple. It has a Number Box for user to be able to input Customer’s Age, and a Check Button control from the Actions category in the ToolBox. When finished we save and close Form Designer to return back to our Flow.
Then, on the Check outcome from our Show Form step we add our Truth Table from the Flows, Rules, Forms and Reports > Rules > [Current Folder] category in the Flow Designer Wizard.
Next, we select Truth Table step on the workspace and Step Information Layer pops up. We locate Inputs section, and for the Age data we pick Select Value Mapping type. Then, using Path picker we select Age outcome from the Show Form step.
Click Add Step button in the Step Information Layer…
From the Favorite Steps in the Flow Designer Wizard we add another Show Form step next to the Truth Table.
Name the Form and click Create to continue.
We add two Buttons to our Form. Then we add three Form Input Data variables that are matching output Data from the Truth Table.
We use these Form Input Data for displaying output information from the Truth Table. Then, we save and close Form Designer.
Back in the Flow Designer we connect Done outcome from the last Show Form step to the End Step, and Back outcome to the First Show Form step in our Flow. Then, we select Show Mapping Editor option for the last Show Form step.
In the Mapping Editor we use Age outcome from the First Form for the Age field, and Outcome Data from the Result output for our Form Input Data fields. When finished, we click Ok to save and close Mapping Editor.
This completes our Flow. We click Debug Flow link on the Top Panel in the Flow Designer to test our Flow.
Note that in Decisions version 3.5 and above, you’ll need to click Test Flow to access the Debugger.
First Form opens in the Debugger and we input 15 as a Value for the Customer’s Age. Click Check…
Second Form indicates that this Customer is not allowed to Rent a Car. We click Back button on this Form…
First Form opens again and we Check the Customer, who is 21…
Second Form opens indicating that this Customer can rent a car, but should pay Young Driver Fee. Therefore, he or she should pay $45 a day. We click Back again…
Finally, we Check if the Customer is over 25…
Second Form indicates that this time the Customer should not pay Young Driver Fee, and the estimate daily rental cost should be $35. We click Done…
Diagram Tab in the Debugger confirms that our Flow was executed with no errors…