Showing posts with label InfoPath. Show all posts
Showing posts with label InfoPath. Show all posts

Tuesday, August 28, 2012

Using Multiple Selection List Box control in InfoPath 2010

Multiple Selection List Box control acts like a list box which can be populated with values stored in a SharePoint list while rendering items with a check box in front of them at the same time.

Here, we will look into two capabilities of this control which are not very straight forward:

  • Retrieving all selected options with a delimiter
  • Show/Hide input details mapped with one of the item in control


Retrieving all selected options with a delimiter

Let's say, you have the requirement of getting all selected items from Multiple Selection List Box control and need to promote these to SharePoint form library.

(To promote this control value, you select 'merge' from drop down at the time of property promotion.)

Here comes the problem !

You may find promoted values unexpected as selected values are merged without any separator/delimiter. This control doesn't provide any option for putting a delimiter between merged values.

To achieve this, you need to work with expressions in InfoPath.

At the time of Submit,
- Create a rule to store provided expression (below) in any hidden control.
- Promote hidden control to SharePoint form library instead of multiple selection list control.

Syntax:
substring(eval(eval(lbControl[. != ""], 'concat(", ", .)'), ".."), 3)     // Store this into hidden control

Description:
It is using eval function of InfoPath which iterates through every item of list box control and put a prefix ", " with item if selected. lbControl is our list box control.


Show/Hide Input Details mapped with one of the item in control

Let's say, we have a requirement of making a control (text box, drop down list etc.) visible or invisible based on selection of a particular item in multiple list box control.

Put your target control in a section and create a formatting rule on section saying like this:

a.)









b.) And, if above condition is true, then hide the section.

Description:
lbRequestType -> This is your multiple selection list box control
"IT Department" -> It is an item populated in multiple selection list box control.