How to restrict duplicate selection in picker control?
From the below example, We need to restrict the user for selecting the mouse for more than 1 time
Note: we are in 4.6.6 version.
There is no way (that I know of) to prevent a user selecting the same value multiple times in a picker control.
I would suggest you look at a different control if you don't want duplicates, such as a checkbox list. You don't seem to have many values in your picker so a different control so a checkbox list might be suitable.
I notice you are on 4.6.6, later versions of K2 have nice controls like the Multi Select.
Thank you very much Andrew.
Yup i'm aware about the multi select control, But the client which i'm working now are still using 4.6.6 version.
I have a big list of items to display, so i can't go with check box list also. Because it is occupying more space on the form.
I do believe u might be able to do the trick if u were using SQL server , then u could create a stored procedure to populate all the records at first time .
and this stored procedure will need to have some kind of filteration .
so first time u open the form , stored procedure will retrieve all records .
second time , u will send the the record the user chose to the stored procedure , in this way
When people picker is resolving , on ur population rule , u will send the existing value in ur picker to the stored procedure and ur stored procedure should retrieve the data execluding the existing records .
Hope it helps! and srry i couldnt go deeper in this but it might help u find the solution.
Your solution will only work if the user opens the picker control a second time. When the user opens the picker control there is nothing to prevent them from selecting the same item more than once.
This can be done by using a couple of hidden fields, a couple of rules, and an expression.
(1) Picker control should be bound to some SMO. In my case, the Identifier configured for the bound SMO is a field called "Code".
(2) Add hidden datalabel to form called "Concatenated String"
(3) Add hidden checkbox to form for "Duplicate Found"
(4) Create an unbound expression called "Add Next Item to String". The expression should be as follows:
If (IsBlank (Concatenated String), Code, Concatenate (Concatenated String ; Code))
** In the expression, drag in the hidden datalabel control for "Concatenated String". For the Identifier (Code) , expand the picker control to see the underlying SMO and then drag over the Identifier field from under the expanded SMO.
(5) Create an unbound rule "Check for duplicate selection" as follows:
If Advanced Condition is true (Concatenated String datalabel CONTAINS Identifier (Code))
Transfer data (set Duplicate found checkbox to True)
Show a message (such as "Duplicate Selection" with value of Identifier (Code))
** As in the expression, for the advanced condition drag in the hidden Concatenated String datalabel, and expand the Picker control and its bound SMO under it to drag in the Identifier (in my case Code)
(6) Add a rule, "When Picker is changed" as follows:
Transfer data (clear any values in the hidden Concatenated String datalabel and the hidden checkbox)
If Picker does not contain a value
Stop rule execution
For All items in Picker list control
If Duplicate Found checkbox = false
Execute unbound rule "Check for duplicate selection"
Transfer expression "Add Next Item to String" into the hidden Concatenated String datalabel
This will show an error message when the picker control is changed and includes a duplicate selection. You can also use the hidden Duplicate Found checkbox to perform final validation on the view/form before submitting. In my case, if Duplicate Found checkbox = true when the user tries to click the Submit button, then I show a validation error message stating that duplicates were found. If you don't want to show the duplicate message upon changing the picker control as I show above, then you could just wait and execute that whole rule as a final step upon clicking the button to Submit.
Hope this helps:)