19. December 2007 08:27
Several days ago Joe and I found ourselves wanting to make sure we made the InfoPath “UserName()” function return all lower case characters and we decided to use the common XPath function “lower-case” but was surprised because it didn’t work. With a little research I found that we could use the InfoPath “Translate” function instead. I must say that it’s a little frustrating that some common XPath functions don’t work and you have to find the work around but if you do any InfoPath development you come accustom to it. Below is what we tried that didn’t work and what we did that did work.
What didn’t work: lower-case(xdUser:get-UserName())
What did work: translate(xdUser:get-UserName(), “ABCDEFGHIJKLMNOPQRSTUVWYXZ”, “abcdefghijklmnopqrstuvwyxz”)
Basically for “Translate” we had to specify every letter in the alphabet in UPPERCASE and then lowercase to make sure every character will get translated. For more information on “Translate” checkout this link http://office.microsoft.com/en-us/infopath/HA012330391033.aspx and do a search for “Translate” for the official description (It’s towards the bottom of the page).
If you foresee yourself using this more often then something to consider is creating a “Template Part” for this. It would be very simple because it would have two fields one called “translate_uppercase” and another “translate_lowercase” and each field default value would be the alphabet in the correct case. Then whenever you would want to use the “Translate” function you would add the “Translate Lower Case Template Part” to the form and build the expression as translate(fieldname, translate_uppercase, translate_lowercase). This would be a lot simpler than typing in all those letters and if you have more than one person doing InfoPath development it would create a standard way of doing it.