Multiple Outcomes From Truth Table

Last 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.

 createTruthTable

Then, we Name our Truth Table and click Create to proceed to the Rule Designer.

 nameTable

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.

 selectMultipleOuts

Next, we click Add New link to add Rule Input Data.

 addNewInput

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.

 defineRuleInput

Then, we click Add New link in the Output section to add Output Data.

 addNewOutput

In the Add Output Data window we add CanRent Boolean data and click Ok to save and continue…

 addCanRent

In the same manner we add IsYoungDriver Boolean Output Data. For this data we check Can Be Null checkbox. Click Ok to save.

 addIsYoungDriver

Finally, we add CostPerDay Int32 Output Data, and check Can Be Null checkbox. Then, we click Ok.

 addCostPerDay

Back in the Output Configurations for the Truth Table we locate Default Output section and select Constant Mapping type for CanRent Output Data.

 defaultCanRent

We leave Value checkbox for the CanRent Output Data unchecked. In this case default output for this Data should be False.

 defaultCanRentFalse

Next, we click [no anchor data] link on the Truth Table to define Rule Phrase for our Truth Table.

 addCondition

We select Age and click Close

 selectAge

Then, we click [n/a] link next to the anchor Data we just selected to add a verb to our Rule Phrase.

 addVerb

In the resulting pop-up window we expand Number Rules category and select Between verb. Then, Close this pop-up window.

 verbAdded

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.

 addRowFirst

We define inputs between 0 and 16 including equals and click Close.

 firstRowInputsDefined

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.

 defineResultsFirstRow

Then, we click add row link to add another definition for our Truth Table Phrase.

 addSecondRow

In the resulting pop-up window we are able to define Inputs and Outputs for the new Row.

 newLookAddingRule

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.

 secondRowAdded

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…

 addThirdRowShowMappings

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.

 thirdRowDefined

Our Truth Table Design is completed now. We can save and close Rule Designer.

 truthTableCompleted

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.

 createFlow

Then, we Name the Flow and click Create to proceed to the Flow Designer.

 nameFlow

In the Flow Designer we add Show Form step from the Favorite Steps in the Flow Designer Wizard.

 addShowForm

In the resulting pop-up window we Name our Form and click Create to proceed to the Form Designer.

 nameFormAge

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.

 checkAgeFormDesign

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.

 addTruthTable

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.

 mappingForTruthTable

Click Add Step button in the Step Information Layer…

 addStepButton

From the Favorite Steps in the Flow Designer Wizard we add another Show Form step next to the Truth Table.

 addSecondForm

Name the Form and click Create to continue.

 nameSecondForm

We add two Buttons to our Form. Then we add three Form Input Data variables that are matching output Data from the Truth Table.

 addFormInputs

We use these Form Input Data for displaying output information from the Truth Table. Then, we save and close Form Designer.

 secondFormDesign

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.

 showMappingForSecondForm

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.

 mappingForSecondForm

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.

3.5 Test Flow Shot

 debugFlow

First Form opens in the Debugger and we input 15 as a Value for the Customer’s Age. Click Check

 checkFifteen

Second Form indicates that this Customer is not allowed to Rent a Car. We click Back button on this Form

 resultsFifteen

First Form opens again and we Check the Customer, who is 21

 checkTwentyOne

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…

 resultsTwentyOne

Finally, we Check if the Customer is over 25

 checkTwentySix

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

 twentySixResult

Diagram Tab in the Debugger confirms that our Flow was executed with no errors…

 flowExecuted

 

 

 

 

 

Additional Resources