I have an InfoPath 2010 form that contains multiple secondary data sources. One of the fields on the form is a multiple selection listbox that pulls its values from a filtered secondary data source. This data source is a SharePoint list that functions like a shopping cart, with each user having several items in the list and they can only see their own items. What the filter does is show any "shopping cart" items where the 'Modified By' is equal to the user opening the form. In this way, I am able to show the user their own cart items and have them select each one to "staple" the item value into the form's XML. The business unit has requested a "Select All" button that will select all of the visible items without the user having to individually check each one, and that's where I'm running into issues. The values in the listbox could be anything out of 1000 possible choices, so there's no practical way to hard-code values.
The filter is currently being applied in the properties of the multiple selection listbox, where I'm telling it to get its values from a secondary data source. I can move the filter if needed. Also, I can change the "Select All" button into something like "Import My Items" if needed, where the button pulls in a filtered subset of the shopping cart list and adds the items programmatically instead. Either way will do, but I haven't had much success with either method.
I have a basic to moderate skill in C# but I'm definitely no expert. Essentially what I'm looking for is code snippets for one of the two options below:
- Looping through the displayed items and checking each one to select it
- Pulling in a filtered subset of the secondary data source with the items already selected
I think I'm close - I've been able to pull in all items from the secondary data source with the items already selected, but any attempts to add a filter to the XPathNodeIterator either have no effect or result in an error. I can post my code if needed, but I have a feeling it may just muddy the waters.
Thanks in advance to anyone who can help.