Using InfoPath 2007 Translate function to do what XPath lower-case function does

by michaellotter19. 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.

Cheers

Tags:

InfoPath 2007 | InfoPath Xpath Functions

Comments (2) -

Paul Galvin
Paul Galvin
12/19/2007 12:19:49 PM #


That's a great tip.  I think I wanted to do something similar earlier this year and abandoned it because I could not get it to work.

Thanks!

  
          

Laurent
LaurentCanada
9/24/2008 4:57:38 AM #

This should be used with caution though because it has a significant impact on performance. The translate function is SOOOO much more demanding than the lower-case function.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About me

Michael Lotter
CFA Institute
SharePoint Solution Architect

 

Calendar

<<  May 2013  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

Month List

RecentComments

Comment RSS