This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Objective

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.

How-to Steps

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

    pop10.png
  • Run the Operators Editable list view and add the following operators [ Greater Than, Equals To, Not Equal To, Less Than ]pop9.png
  • 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.popresult1.png
  1. 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.
     Pop1.png
  • Add a condition check to see which question is selected

    pop2.png
  • 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.
    pop6.png
    pop7.png


This solutions' tested result can be seen below.

popresult2.png