Calculation on Forms Using Truth Tables
  • 01 Oct 2021
  • 2 Minutes to read
  • Dark
    Light

Calculation on Forms Using Truth Tables

  • Dark
    Light

Article Summary

Overview

Using a Truth Table, users are able to calculate values and display them on a Form. 

Example

In this example, a user will make selections from a list of medical services and prescription medications on a Form. All of the selections will be added dynamically and displayed as a total cost on the Form.

  1. In a Designer Project, click CREATE FLOW and select Flow. Name the Flow and click CREATE.
  2. Click the Done path of the Start step. Select Show Form and click ADD.
  3. On the Properties panel, click PICK OR CREATE FORM and click CREATE. Select Form, name the Form and click CREATE.
  4. Configure the Form to have two Labels (Services, Prescriptions), two Multi Drop Down List components (ServicesList, MedicationList), a Number Box (TotalCost), and a Button component (CLOSE).
  5. Configure the ServicesList to have Static String items of "ADHD Testing", "Blood Pressure Monitoring", and "EKG".
  6. Configure the Prescriptions list to have static String [Text] items of "Med1", "Med2", and "Med3".
  7. Navigate to the FORM RULES category on the Properties panel by deselecting the Form. Click ADD.
  8. Name the Flow and click EDIT RULE FLOW.
  9. Attach a Run Truth Table step to the Done path of the Start step. Click PICK OR CREATE TRUTHTABLE on the Properties panel and click CREATE. Select Truth Table, name the Truth Table and click CREATE.
  10. Click SETUP INPUT DATA and click DEFINE. On the Input Data window, enter "Services" as a String [Text] Type and select the IS LIST checkbox. Click Save and close the window.
  11. Click Select Data Element and select Services. Click CLOSE.
  12. On the Pick Verb dialog, select List Contains Any. Click CLOSE.
  13. In the cell under Services List Contains Any, enter the values from the ServicesList drop down list. Click Click To Add Row to add the other value options.
  14. Hover over the Default Output Data column and click the pencil icon. Change the Type to Decimal [Number]. Click OK.
  15. In the cells, enter "250", "125", and "400". Click Save and close the Truth Table.
  16. Add a Sum step to the Done path by navigating to All Steps [Catalog] > Data > Numbers. Click Unknown and select Select from Flow. Select Result and click DONE.
  17. Add a Run Truth Table to the Sum step. Configure the Truth Table to have a Medication String [Text] list. Enter the values from the drop down list for Medications with the values of "100", "389", and "2559". Save and close the Truth Table.
  18. Rename the Output to Result2. Add another Sum step and select Result2 as the input.
  19. Select the Done path. Navigate to All Steps [Catalog] > Data > Numbers. Select Add and click ADD.
  20. Map in Sum_Output for Value1 and Sum1_Output for Value2.
  21. Click the Done path. Enter "Set control value" and select the Set Control Value step and click ADD.
  22. Click Unknown next to Form Control and select Select From Flow. Click Form Data, select TotalCost [NumberBox], and click DONE.
  23. Map Add_Output to Value and click DONE. Connect the Done path to the End step.
  24. Select the Services Truth Table and click Edit Input Mapping.
  25. Expand the Form Data category, select MedicalServicesList [MultiSelectDropDown], and connect Selected Item to Services. Click OK.
  26. Select the Medication Truth Table and click Edit Input Mapping. Map Selected Item from MedicationList [MultiSelectDropDown] to Medications. Click OK.
  27. Click Save to save changes to the Flow and close Flow.
  28. On the Add Active Form Flows window, select the SelectionChanged checkbox under the MultiSelectDropDown lists and select the Enter checkbox for TotalCost. Click OK to close the window.
  29. Save and close the Form and connect the Button path to the End step.


Debug

  1. Click Debug on the top action bar. Click START DEBUGGING.
  2. Select different options from the drop-down lists to see the number box dynamically update and add the values from the selections. Removing selections will also update the number box.




Was this article helpful?