Home

Cleaning Up UserName() Function using Infopath

Lul Woreta
Senior Member

I have an InfoPath form published to Office 365, SharePoint Online, which uses the UserName() function to identify the creator of the instance as the project owner.

 

For Example:

i:0#.f|membership|lwilliam@abc.com

 

I want to display only "lwilliam" to my infopath form. I don't need the rest of unnecessarily item. 

 

I just tried using : substring-after(userName(), "i:0#.f|membership|"), but the result is "lwilliam@abc.com".

1 Reply

Is there a reason you want just part of an email and not their actual name? There is a great post on how to retrieve various user information: https://www.qdoscc.com/blog/how-automatically-retrieve-current-username-infopath-sharepoint-list-for... 

 

If you don't mind "helper" fields that you hide on the form you can always have two fields.  One named "emailAddress" that says: substring-after(userName(), "i:0#.f|membership|")

 

And the second could be the field you want by putting in: substring-before(emailAddress, "@abc.com")  

 

You would end up with an extra field that you could hide, but it should get you the end result that you are looking for.  You could also use the post listed above and choose WorkEmail instead of PreferredName and put in in this formula instead of emailAddress: substring-before(<follow post directions here>, "@abc.com")

 

Tim

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Extentions Synchronization
ChirmyRam in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies