Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Goodbye WhoAmI! Hello userName()

Goodbye WhoAmI! Hello userName()

  • Comments 18
Anyone who's tried to get the username of the person filling out their form in InfoPath 2003 knows the WhoAmI web service. That was the only way to get the username without writing Visual Basic or C# managed code and using System.Environment.UserName.
In InfoPath 2007 we built an easier way.
Announcing a new formula function: userName()
Now you can simply set the default value to the current form-filler's username. No code, no data connections, no custom web service. Just use the formula dialog and select the function from the category "All":
To get a default value like this:
If that's too easy for you, use it in script
If you're writing script anyway, or if you need to check this value as part of a bigger algorithm and don't want to persist the username anywhere in the form, then you can also access this value in script:
Of course, you can also use this in C# or Visual Basic, but you could always use System.Environment.UserName, so that's nothing new.
Either way requires Domain Trust
For security reasons, either approach will make your form require domain trust, so you'll need to publish the form to a shared location (like Windows SharePoint Services) for the function to work.
Leave a Comment
  • Please add 5 and 6 and type the answer here:
  • Post
  • email id: could you please help me.

    im doing project with ns2.

    my problem is "how to make a node to dead randomly in ns2

  • Hi There,

    How can I get Displayname/Preferred Name out of the username() function.



  • From what source does the userName() determine the value? The reason I ask is that we have encountered some cases where it appears that a few users were getting obsolete information. We then add the user to a group under the site collection in which the application is located, and then have the user try again, and the user succeeds. It is as if some users are recognized while others are not.

    Is there a function that InfoPath could run that would ensure the user would be recognized?

Page 2 of 2 (18 items) 12