Overview
In this scenario we had a set of Interview questions and based on responses to the questions we need to be able to hide and show related questions. This meant that the form was quite dynamic as each selection a user made was either showing or hiding a set of fields.
North52 Decision Suite
The North52 Decision Suite solution works like this:
- An entity called Interview has been created with 10 fields fields created
- The 10 fields are all simple Yes/No fields for this example
- A Formula is set up for the OnLoad event of the form and OnChange event for each Question
- The form is designed so that all questions are hidden by default except Question 1
- Each time the formula executes it evaluates all questions and determines the set of fields to be shown and hidden
Formula
Set up
- Create a new formula, setting the following values in the Formula Guide:
- Source Entity set to Interview
- Set Formula Type to Client Side - Perform Action
- Select the Decision Table editor
- Change the Name of the formula to Interview Questions - Hide - Show
- Expand Source & Target
- Ctrl-click to select the OnLoad and OnChange events for the relevant form
- Click Save
Question Set 1 Sheet
- Rename the sheet by double-clicking on the sheet tab and entering QuestionSet-1
Conditions
- Select cell A2
- Click on the Source tab
- Expand the Source node
- Find the field Question1 {Value} and click on it
- Select cell A4
- Under the Source node, expand the field Question1 {Value}
- Click on Yes to add it to cell A4
- Select cell A5
- Under the Source node, expand the field Question1 {Value}
- Click on No to add it to cell A5
- Select cell A6
- Enter the text: '?' (this means an empty or Null value)
Actions
- Select cell C2, right-click and select Insert > Insert Action
- Select cell B2
- Click on the Source tab
- Expand the Source node
- Find the field Question2 {Value} and click on it
- Select cell C2
- Find the field Question3 {Value} and click on it
- Select cell B4
- Select the Functions tab
- Search for showfields, then Ctrl-click the function name to add {{{ShowFields}}} to cell B4
- Select cell B5
- Search for hidefields, then Ctrl-click the function name to add {{{HideFields}}} to cell B5
- Select cell B6
- Ctrl-click the HideFields function name again to add {{{HideFields}}} to cell B6
- Select cell C4
- Search for showfields, then Ctrl-click the function name to add {{{ShowFields}}} to cell C4
- Select cell C5
- Search for hidefields, then Ctrl-click the function name to add {{{HideFields}}} to cell C5
- Select cell C6
- Ctrl-click the HideFields function name again to add {{{HideFields}}} to cell C6
- The sheet should look like this:
Question Set 2 Sheet
- Right-click on the Decision Sheet
- Select Insert > Insert Duplicate Decision Table
- Rename the sheet by double-clicking on the sheet tab and entering QuestionSet-2
- Repeat the conditions and action steps replacing the condition with Question 2 and the Action columns with Question 4 and 5 respectively
- The sheet should look like this:
Question Set 3 Sheet
- Right-click on the Decision Sheet
- Select Insert > Insert Duplicate Decision Table
- Rename the sheet by double-clicking on the sheet tab and entering QuestionSet-3
- Repeat the conditions and action steps replacing the condition with Question 3 and the Action columns with Question 6 and 7 respectively
- The sheet should look like this:
Publish and Test
- Click Save
- Select N52 Commands > Publish Formula
- Perform your testing