+44(0)1908738254
YOUR EXPERT RPA PARTNER

Team up with our RPA strategy and tech specialists for maximum automation impact

Find out more
Harness the power of UiPath in your business.
WATCH NOW

Save money and spend more time on priority work.

Book consultation
READY, SET, AUTOMATE

Let's choose, design and deploy a process automation solution for your business.

Find out more
TRANSFORM YOUR BUSINESS

Let's analyse your business to discover opportunities for innovation and automation.

Find out more

Begin your business transformation journey

Book consultation
AUTOMATE EVERY FUNCTION

Automate where it matters most. Scale to solve challenges in every area

Find out more
GIVE EVERY TEAM THE TOOLS FOR SUCCESS

Equip people with user-friendly solutions that save time and make work easier

Find out more

Which business problem
can we solve first?

Book consultation
31 January 2015

Saving and Loading data with a K2 SmartForms CheckBox List Control

The K2 SmartForms CheckBox List Control is a very useful control when we need to display a set of different options for the user to choose from. There are a few different approaches to loading the checked values and saving them. We will cover saving data with the XML return value from the K2 SmartForms CheckBox List Control and loading data with a delimited string.

K2 SmartForms CheckBox List - Saving & Loading Data - 1

K2 SmartForms CheckBox List – Saving & Loading Data – 1

K2 Automated Testing Software

BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.

 

Free K2 Five Upgrade Review

Configuring the K2 SmartForm CheckBox List Control is similar to any other data driven K2 SmartForms Control. In the Data Source section we need to specify the type as a K2 SmartObject, select our K2 SmartObject and specify the value & display fields. The value will be used in both the saving and loading of the data whereas the name is only for display purposes on the righthand side of each Checkbox.

K2 SmartForms CheckBox List - Saving & Loading Data - CheckBox List Properties - 2

K2 SmartForms CheckBox List – Saving & Loading Data – CheckBox List Properties – 2

SmartForms CheckBox List – Saving & Loading Data – CheckBox List Properties – 2
To load the K2 SmartForms CheckBox List Control, we need to transfer a string containing values corresponding to the value of the K2 SmartObject as specified in the control’s properties. The values in the string need to be semi-colon delimited. For this example we used Id as a value, the string returned would then look something like “1;3;8”.

The load method can be called when the K2 SmartForm executes initialise. In the rule definition first create a rule that will populate the K2 SmartForms CheckBox List Control with all the data, then create another rule that will return only a semi-colon delimited string containing the values of the checkboxes in the list that should be checked.

K2 SmartForms CheckBox List - Loading Data - Rule Definitions - 3

K2 SmartForms CheckBox List – Loading Data – Rule Definitions – 3

In the output mappings section in the rule configuration (the rule returning the semi-colon delimited string) simply drag the return parameter into the configuration space of the K2 CheckBox List Control. This will transfer the data to the control causing the checkboxes in the list with values corresponding to those in the semi-colon delimited return string to be checked.

K2 SmartForms CheckBox List - Loading Data - Rule Configuration - 4

K2 SmartForms CheckBox List – Loading Data – Rule Configuration – 4

When saving however, the data does not get returned as a delimited string but as an XML string.

K2 SmartForms CheckBox List - SavingData - XML Preview - 5

K2 SmartForms CheckBox List – SavingData – XML Preview – 5

On our save event we add a rule calling our save method. In the input mappings section of the rule configuration we drag the return parameter into the configuration space. When the method executes the input value gets passed through as an XML string as shown in fig 5.

K2 SmartForms CheckBox List - Saving Data- Rule Configuration - 6

K2 SmartForms CheckBox List – Saving Data- Rule Configuration – 6

We will have to extract the values from the XML in order to save the checked item data.

K2 SmartForms CheckBox List - Saving Data - Extracting Data from XML - 7

K2 SmartForms CheckBox List – Saving Data – Extracting Data from XML – 7

About K2 SmartForms
K2 provides a faster, easier way to create forms for business applications. With drag-and-drop tools, code isn’t necessary, and a powerful rules framework allows you to stay in control.

Need further technical advice or support?