How to convert text to upper or lower case in InfoPath

If you're developing SharePoint forms with extended functionality, then you've most likely already been exposed to InfoPath.  You know, that thing that Microsoft said was dead years ago? :-)
Unfortunately, InfoPath doesn't have the maturity of something like Visual Studio and C# when it comes to text handling.  It would have been great if we could have had access to a .ToUpper() or .ToLower() method when dealing with text, but alas, we do not.
To that end, we have to use a workaround leveraging the translate() method.  In order to generate the equivalent of .ToUpper() which converts all text to uppercase, you'll need to use this:

translate(., "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")

Vice versa, to get a .ToLower() equivalent which converts all the text to lowercase, you'll need:

translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")


Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.