Monday, August 23, 2010

Getting lower case (lcase) and upper case in the infopath using translate function

 

translate(Field,"ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz")

Lower Case in InfoPath

translate(../d:Owner,"ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz")

Upper Case in InfoPath

translate(../d:Owner,"abcdefghijklmnopqrstuvwyxz", "ABCDEFGHIJKLMNOPQRSTUVWYXZ")

2 comments:

Anonymous said...

Thank you for this! I have a question - I am an IT Security Analyst and am responsible for creating IDs in our organization. We have a form with a First Name, Middle Initial and Last Name. My formula looks like this:

translate(concat("IDIR\", substring(FirstName, 1, 1), substring(MiddleInitial, 1, 2), substring(LastName, 1, 7)), "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")

This will take the first letter of the first name, the Middle Initial, and up to 7 characters of the last name to make up an 8-character user ID, and convert those in to uppercase beginning with "IDIR\".

It does not address the issue of if a person does not have a middle initial to make up 8 characters - it will appear as 7 characters only.

How would you write a formula that says, "if the person does not have a middle initial, take the first letter of the first name, and 7 characters of the last name to make an 8-character user ID"?

dan.smith@shaw.ca said...

Let me rephrase the question - How would you write a formula that if the user does not have a middle initial to take the first TWO (2) characters of the first name, and then up to SIX (6) characters of the last name to make up 8 characters?

Sorry, I got a little ahead of myself.