InfoPath DropDown List doesn't match on items in list

When populating InfoPath DropDown lists with values and then binding the dropdown to a field in your main datasource you'll sometimes see the bound value instead of its corresponding text value in the dropdown on load. It seems slightly confusing given that the entry containing your bound value is actually in the list, but it doesn't match.

Most likely this is a string casing problem. I've got a dropdown bound to a Sharepoint (WSS) UserGroup service and bind the value to @LoginName. These values are typically DOMAIN\ My main datasource however, lowercases all reference variables to avoid any confusion. Since I don't control the formatting done by the Sharepoint service my best bet is to lowercase the values of the @LoginName attributes in my secondary datasource.

First off I got excited by this post on the InfoPath Blog which feels a bit like calling C# or javascript code from regular XSLT transformations. The blog describes calling code to evaluate conditions, not setting DOM values, and furthermore there are no events you can respond to in order to call the code that will manipulate your secondary datasource values and setting them toLower.

Since I query my UserGroup service on form load, and this occurs before the Load event in script I was able to perform toLower (or more precicely toLowerCase()) in the load event like this:

var objXMLNodes = XDocument.GetDOM("UserService").selectNodes(//@LoginName);
for(i = 0; i < objXMLNodes.length; i++)
      objXMLNodes(i).text = objXMLNodes(i).text.toLowerCase();

Filed under:


No Comments