I'm working in the New Responsive Designer in Nintex Forms for O365. I'm using a People Picker control to select an employee. Then I have created a form variable utilizing the userProfileLookup function to get the user's email (ex. username@company.com). Works fine.
Now I need to create another form variable that removes the "@company.com" from the email and only has the "username" part stored in the variable. Not having any luck so far. Any help is appreciated.
Page 1 / 1
I was able to figure this scenario out and answer my own question. I actually went a different route and used a People Picker field to get the Employee username to use in the form. I thought I would share how to do this in case someone else needs to do the same thing in a form.
Add a People Picker control to the form (Name = Employee).
The Employee control returns a value like: i:0#.f|membership|mjones@company.com;#Jones, Mike
Create and configure a form variable.
Name = txtEmployeeUsernameOnly
Type = Text
Value = replace(replace([Form].[Employee], "i:0#.f\|membership\|", ""), "@([(.)(#)(,)(;)\s\w]+)", "")
This formula yields only the user name ("mjones") and stores it in the variable.
You can add the form variable inside a Label control to see the value after you pick a user in the Employee field.
@bamaeric ,
Hi! Ok, so I have come across this same issue as above and cannot for the life of me fix it! So I applied your steps but I’m coming across error… could you assist?
@jpacheco I swear the formula I used before worked. Try the formula below instead.
This will return the user name part of the email address before the @.
@bamaeric ,
Man, you’re a genius and thanks so much, it worked!! But just one more question...is there a way to remove the period between the first and last name or?
You rock! Thanks
@bamaeric ,
Sorry, I forgot to add a screen shot… but currently the output is like you say the username part just before the @. So in my case the output is like so below…
Is there a way to capture the name at the very end like in the screen shot below (underlined)?
To replace the period in the string with a space, I would first create another form variable. Then use the previous variable you configured to get the username in this formula:
replace((Form]..txtUsername],"".]"," ")
To get the name at the end of the string, you can use this formula:
replace((Form]..Employee],"(^.*?(?=;#);#)","")
This will return all the characters after the ;# pattern.
@bamaeric ,
You are a rockstar and thanks for the explanation! I see where I went wrong thank you!