Removing unwanted characters from username field using infopath

12k Views Asked by At

Can anyone tell me how to remove unwanted characters from username field. ex: i:0#.w|abcventures\sreekiran.k I need to remove the characters which are generated before abcventures\sreekiran.k.

I have used translate() to eliminate those characters, but, it is removing i & w characters also, from the username.

3

There are 3 best solutions below

1
On

To expand on the current answers, I think they meant to use substring-after(). This will do the trick:

substring-after(userName(), "i:0#.w|")

0
On

Use substring-before to remove those characters.

0
On

To expand on Mekalikot's answer -

substring-before(userName(), "i:0#.w|")

Will return just the string after the "i:0#.w|" from the user name function. If the user name function does not include that string, however, the formula will return nothing. Since you'll get a different value from the user name function in preview vs. the browser, you'll probably need to test this with the published form.