I have a people picker with more then one user ,when i click submit on the form i want it to create an individual item in the list for each user in the picker filed? currently it creates one item with all the users.i want an item for each user on to the list.achived this using javascript presave() method but want to know its possiblilty in k2?
One possible implementation it to call a workflow and pass the picker control/string into the workflow.
The result of a Picker control is semi-colon delimited list (by default), and within the workflow you can use the foreach loop to loop through and create an item for each user; as the foreach event does accept a semi-colon delimited list.
Good Day Ron
I believe that the for each rule within K2 designer should help you to achieve this goal.
The for each rule can be called on the picker (list control), when the submit button is clicked, you can then design the for each rule to preform a create into the SmartObject bound to the list - this would create a new record for the selected values in the picker control.
You do have to note thought that the values within the picker control will be seen as a single value, even if you have multiple values selected in the picker control all the selected values will be seen as a single string which means that if you selected A,B,C that would exactly be how the create method will stored the new record. The create method cannot identify that it should be 3 different records instead. You could however look at using expressions to trim the values down in order for the input property that needs to be provided to the create method to recieve a single one of the selected values one at a time, I have not tested this but it might work.
Kind Regards
Raymond
Good Day Ron
After doing some more testing I managed to get this in a working state where you can select multiple users from the picker control and save them each individually into their own records using the for each rule.
Please see the steps I followed to achieve this below:
- Create a view containing a picker controla and a button
- Configure the picker ontrol to a SmartObject
- Now configure the button with the below rule construction
When Button is Clicked
(configure)
- You can then configure the "Then on View101 SmartObject, execute its Create method
(configure)" rule with the below properties
Kind Regards
Raymond
Good Day
I created a KB article regarding this issue and this solution should someone else run into the same issue they would have exact steps to follow in order get the underlining issue resolved
The KB Article can be accessed from here:
https://help.k2.com/support-services/kbs100082
Referencing Other Exisitng Community Postings:
Note: Should you feel that this post is of use and or an accurate solution to the raised question, I kindly encourage you to mark it as such using the 'Mark as Solution', 'Kudo' andor ‘Me Too’ options.
Kind Regards
Raymond
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.