This topic illustrate on how to create validation rule for a multi select control for K2 SmartForms. For list view, we can do it easily using the for each condition rule and loop through the list. This can be done for multi select control as it just need more tweak on the rules.
This idea comes about when there is a requirement that the user would like to view the list uploaded files on the multi select control. However, only certain files allow to be selected.
How it works
Basically the upon every selection, we will validate against the specific rule. If it passes the rule, we will store the selected data into a data label. Otherwise, we will revert the multi select data into the data label that has the previous control value.
- Create a multi select control and create some static values for the control
- Create 2 data labels, one is for storing of multi select value and another is for validation purpose.
- Add a rule for the multi select control on change
- Add in the transfer data
- Add in for each condition for selected list control (multi select control)
- Add in the advanced condition under step 5. This is to specify invalid condition. In this case, i do not want the list of data that contains “.xls” to be selected.
- Add transfer data rule
- Add in rule for If control (Validation data label) contains specify content (false)
- Add in transfer rule for step 8. Revert the control data as the validation is false.
- Add in else rule
- Add in transfer rule for step 10. Save the current control value.
- And you are done!