Creating and Using Truth Tables

Last Updated: 07/26/2016 Introduced in Verision: 2.0

Truth tables are rules that compare the possible combinations of multiple inputs, allowing the user to arrive at different outcomes depending on the specific combination.


In our example flow, we will use a truth table to determine the colors to which a Car can be repainted. If a car is older than 2011, it can be repainted to any color. If a car is newer than 2011, it can only be repainted to one of the standard colors: red, yellow, black and blue.

This example assumes that the form with which we’ll change a Car’s color has already been designed, as well as the flow in which we will use it.



We will begin in a Designer Project folder by selecting the Create Rule > Create Truth Table action.



In the New Truth Table pop-up, name our truth table “Color Year Truth Table” and click OK to open it in the Rule Designer.



In the Flow Data section of the Properties tab, select the Add button. In the resulting Edit object pop-up, define the first variable of our truth table – a String named “Color.”



Next, define an Int32 named “Year.”



In the Truth Table View tab, select the [no anchor data] link and select Year [Int32].



Next, select the [n/a] link and select Number Rules > Less Than for this condition’s comparison operator.



Next, add another column to our truth table by clicking the add condition link.



In the second column, create the condition: “Color In List.”



Next, define the values of our truth table. In the first row, define as True all tests of the rule where the year is less than 2011. In the first row, under Year Less Than, select the [ignored] link, change its mapping to “Constant” and define its value as “2011.”



Ignore the Color for this condition and set the Result to True.



Next, click the add row link to add another row to our truth table. We will ignore the Year for this condition and click the [ignored] link under the Color In List column. In the resulting pop-up, define the Mapping Type as “Constant” and fill in the list of valid colors for a car sold during 2011 or later: Red, Yellow, Blue and Black.



We will set the Result of this condition to True.


In the Inputs section of the Properties tab, we will define the default outcome as False, so that only the two conditions which we defined earlier will evaluate as True.
Note that truth tables output an array; use the [value].First variable as input for a subsequent step in cases where only one piece of information is needed from the truth table output.

This completes our truth table, so we will save it and close the Rule Designer.



To use the truth table we’ve just created, we will make it a validation rule for the Change Car Color form that we’ve pre-designed. We will navigate to our Designer Project folder, select the Change Car Color form and select the Edit link to open it in the Form Designer.



To add our truth table as a validation rule, we will expand the Explorer tab, select the Surface element, and recollapse the Explorer tab. In the Properties tab, under the Custom Validation Rules section, we will see a list of validation rules for our form. We will select the Add button.



In the resulting Edit object pop-up, we will name our validation rule “Newer than 2011 must be standard color”. In the Rule dropdown, we will select the Color Year Truth Table rules. In the ValidationBreakText field, we will define the message: “Cars newer than 2011 can only be repainted to a standard color.”



In the Inputs section, we will select our rule’s Color input and select the Edit button.



Because we want our rule to use the color selected in the dropdown as its Color input, we will select Form in the InputType dropdown and select Color in the FormDataName dropdown.



We will edit our rule’s Year input in much the same way, with one difference. Because we do not have a Year control on our form, we want our rule to use an input that’s not associated with a control. We will select InputData in the InputType dropdown and type “Year” in the FormInputName field.



This will complete our validation rule, so we will save it. This also completes our form, so we will save it and close the Form Designer.



Our example flow has already been designed as a folder behavior action for Car folders, so we will navigate to a Car folder and select the Change Car Color action.



Because this car was built after 2011, we cannot change its color to “Special Green” – a color that is not in our list of acceptable colors.



However, when we navigate to the folder for a car built prior to 2011, we can change its color to any color that’s available, including “Special Green”.



Additional Resources