How to populate the drop-down control and filter it based on a different drop-down control selection, when they do not have any relationship with one another.
Before You Begin
First you need to identify which question should display which operator, as we already know that a particular question has a particular operator value.
So let's use this example: If the question is "Is this Valid?" then the operator should populate the operator drop-down list with "Equal to" and "Not Equal To".
To allow the operator to return the correct value it would first need to filter the value upon a re-population of the operators drop-down list, after a condition check against the questions' drop-down list has been identified as true.
For example: If the question is "Is this Valid?", then on the questions' drop-down list we would need to check if the drop-down list is equal to "Is this Valid?" This will then validate to either true or false. If it validates to true then the operators drop-down list should be re-populated and a filter should be added to the re-population rule specifying which operators should be made available in the operator drop-down list when the questions drop-down list is equal to the question "Is this Valid?"
If the question changes, this entire condition should be re-executed.
- Get setup first:
- Create a SmartObject and call it 'Questions' with an ID=Autonumber property and a Questions=Text property.
- Create another SmartObject and call it 'Operators' with an ID=Autonumber and an Operator=Text property.
- Generate an Editable list view for each of the above SmartObjects.
- Run the Questions Editable List view and add some questions.
- Run the Operators Editable list view and add the following operators [ Greater Than, Equals To, Not Equal To, Less Than ]
- Create an Item View and add two drop-down lists to the canvas. Configure the first drop-down lists Data Source to the Questions SmartObject and the second drop-down lists Data Source can be configured to the Operators SmartObject.
- Now to add the rules, that will do the check:
- Since the drop-downs already have data sources connected to them at this point, that will mean that the views "Initialize" rule would have auto generated population rules for each drop-down list. You can disable or remove the Populate rule for the Operator SmartObject as we are going to call it somewhere else. This step is optional depending on if you need the drop-down list to be populated on initialize or not.
- Add a new rule on the questions drop-down list for when it gets changed.
- Add a condition check to see which question is selected
- Add the Operators populate list control with data rule and add your filters depending on what should be returned when the specified question is selected.
This solutions' tested result can be seen below.
- Add a data label, set its visibility to hidden.
- When the questions drop-down list is changed instead of having a condition you can transfer data which will transfer the selected drop-down lists items ID/Question to the data label.
- On the data label change add a advanced condition rule the checks if the data label value is equal to the drop-down lists ID/Question (Depending on whether you previously used ID/Question). Then populate the Operators drop-down list.
- On the Operators drop-down list populate rule, add a filter that checks if the ID/Question (which ever was used) is equal to the data label and that should do the trick.