Skip to main content

K2 Smartforms: Using Checkbox Lists


I need to set up a number of Checkbox lists to obtain data regarding a specific event. The checkbox options are stored in a SQL table as seen below:


SELECT    pOption_ID],


                 ÂType_ID],


                 ÂOption_Description]


 


FROM       rFleet_Management].sdbo]. Accident_Option]


 


The options are grouped by OPTION_ID so that they can be displayed in the Checkbox lists as seen on the attachement


 


I would like to store the resulting selections in the following table:


SELECT    nIncident_Number],


                 aType_ID],


                 _Option_ID]


 


FROM       dbo].>Truck_Accident_Conditions]


 


Is there any way of iterating through the selected options from a Checkbox List and saving each as a record in a table.


14266iF880902320330A4E.jpg

Hi


How did you get a dataset to display with a checkbox ?


I am needing to do something similar, ie: display items from a table and allow the user to tick which ones they want to select.


SmartForms doesnt seem to have this functionality using a list view.


Based on my understanding, in K2 SmartForm check box list value is store as XML in SQL Server. In such case, you can create a custom SP which will parse the XML and update your table.


Please note that you might want to also store the XML because when you reload the control with selected item then you will need this XML data.


Guys,


you are correct...!!!


CheckBox list data always select in the xml format, however if you wan to store the data into the custom DB, you dont have explictely run the Stored procedure which split the data in xml format, you can still directly store the value property in to DB, i had the same requirement and mplemented it without any custom SP.


 


But i have another requirment, where i have to display all the checkbox list items if the parameter value is null, else i need to display all the checkbox list items with some of them by default checked in.. Im confused how to configure the Data source for this condition. Please help needed.


 


Thanks and Regards,


Prajwal Shambhu


Prajwal,


I'm also stuck saving ( loading) checkbox list values into (from) the database.


Can you please provide me with examples.


 


Thanks


 


Bibi


Hi Bibi,


Can you please elaborate your requirement, i'm able to load selected items on another checkbox list control, however my requirement, is to load the data items onto the same Checkbox list control, which being used to display all items to let user to select multiple items.


 


Thanks and Regards,


Prajwal Shambhu


Hi Prajwal,


I've got 3 smartobjects: User, Group and UserGroup(Composite smartobject). i'm using SQL database for the three smartobjects


In the user item view, i want to bind  the checklist control to the list Method of the Group Smartobject  to show the availble groups and when the Create button is clicked, i want the items that are checked to be created in the usergroup table.


I found some instructions on http://help.k2.com/en/kb001304.aspx but i cant save recrods from the checkbox list.


 


Did you try the same package install in other machine, because some times, because of Work24 patch not applied to your server this issue will happen,


had you tries the same scenario by using smartbox servicce instead of SQL, just to confirm all the rules you have set is correct...


I have implemented this scenario using smartbox service and its working fine, im able to load, create and save checkbox list items,


I have sent you rules detail i have set at form level, you can verify them once..


At Form level,


My View:



Rule at Create Button;



Rule when my view initialized..



To save checkbox list items:



Rule at Form level:



 


Hope it would help you...!!!


 


Thanks and Regards,


Prajwal Shambhu..:)


Hi Bibi,


I have cracked the issue and its working fine for me,


Only thing we need to set, to load the data is, once after data populate into List view, we need to execute Load method of the  composite smartobject, please make sure, while configuring the data source to the checkbox list, you have selected value as ID, which you will be passing as input parameter to the LOAD method.


 


Thanks and Regards,


Prajwal Shambhu


Hi Prajwal,
Thanks for the feedback but I'm using an item view and once the load button is cliked i want the checkbox list to be selected for that specific ID.
In the load button rule, i've added the rule to execute  the Load method of the composite smartbject and passed the ID as parameter but  I cant get the checkbox list to check the items specific to that ID.


 


Regards,


 


Bibi


 


Hi Prajwal,


After executing the load method of the composite smartobject, only one item is selected on the checkbox list. How can i make other values to be selected?


Can you please post the screenshot of the rule where you are loading data into checkbox list?


Regards,


Bibi


 


Hi PSwanepoel,


 


Please follow these steps to get answers to your questions:


How can i make other values to be selected?


Rule where you are loading data into checkbox list?


 


Steps:
1) From K2 Designer create a SmartObject with three properties (ID=Autonumber, ItemName=Text, SaveItem=Multivalue).
2) Generate a Item View from this SmartObject.
3) Run the view, Using the view add the values you are attempting to use in the checkbox list.
Example: in the checkbox list select option "1" then give it a name in the the "ItemName" and click create, do the same thing for chakbox list option "2" and "3" then you start checking multiple options like "1" and "2" then click create until all combinations have been met.
4) Now using the SmartObject Test Tool execute the SmartObjects GetList method and notice that each record has some xml which defines the selection that was made in the checkbox list, this xml will be used later as a condition in a rule to determine which checkbox was selected.
5) Now create a new view.
6) Edit the new view and add a checkbox list, provide it with static values (1, 2, 3)
7) Now add the following Rule structure based on the values used in your checkbox which was saved as xml to the SmartObject.


When Check Box List is Changed

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>1</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 1
then stop rule execution

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>2</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 2
then stop rule execution

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>3</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 3
then stop rule execution

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>1</value></field><field><value>2</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 1&2
then stop rule execution

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>1</value></field><field><value>3</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 1&3
then stop rule execution

if an advanced condition is true                      -->CheckBoxList =Equals <collection><object><fields><field><value>2</value></field><field><value>3</value></field></fields></object></collection>
then complete the following one after another
then show a message to the user (configure)  -->Message will show 2&3
then stop rule execution


8) After all combinations of the rules have been created and structured into the rules then you can run the form and it should work as expected.
Please find a the package attached, displaying the above scenario created using the steps.

Note: this will work if you follow the whole procedure with a SmartObject as the checkbox lists data source as well.


 


Referencing Community Post: http://community.k2.com/t5/General/Filtering-a-checkbox-list-on-multiple-values-in-Smartforms/td-p/67514



Kind Regards,
Raymond


Reply