Solved

Get Username for Infopath Form

Posted on 2007-04-03
4
4,671 Views
Last Modified: 2007-12-19
How do I get the username to be used in a field in an Infopath Form on a Sharepoint Site
0
Comment
Question by:Edwik
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:Shailaja Kumar
Comment Utility
hi Edwik,

Your question is not very clear. According to my understanding,

1. If you want an infopath field to populate the current SYSTEM username then infopath has an option of providing a rule that retrieves the current system username.
http://blogs.msdn.com/timpash/archive/2006/08/22/712663.aspx

2. if you want an infopath field to populate the current SHAREPOINT username then you have to write some code behind that uses the SharePoint Object Model to retreive the current SharePoint Username

regards,
Shaialja Kumar
0
 

Author Comment

by:Edwik
Comment Utility
I am using Infopath 2003 and the Username Function is not available.  If you know of a better way to do this than what I have come up with please let me know

I Ended up using an ActiveXObject to get the data in the Open event

//Create a WScript.Network object, which provides access to the user data
  var objNetwork = new ActiveXObject("WScript.network");


  //Retrieve the UserName and write it into the my:UserName field
  XDocument.DOM.selectSingleNode("/my:myFields/my:UserName").text =
  objNetwork.UserName;


  //Retrieve the UserDomain and write it into the my:UserDomain field
  XDocument.DOM.selectSingleNode("/my:myFields/my:UserDomain").text =
  objNetwork.UserDomain;


  //Retrieve the ComputerName and write it into the my:ComputerName field
  XDocument.DOM.selectSingleNode("/my:myFields/my:ComputerName").text =
  objNetwork.ComputerName;
0
 
LVL 11

Accepted Solution

by:
Shailaja Kumar earned 500 total points
Comment Utility
hi Edwik,

I would suggest using .Net, you get a much easier solution.You just have to use the downloadable plugin to install and start developing code for infopath in .Net. The System.Environment.Username can be used to retrieve the current username and the System.Environment.UserDomainName can be used to retrieve the domain name.

All the very best,
Shailaja Kumar
0
 

Author Comment

by:Edwik
Comment Utility
Unfortunately I am still looking for a method to get the Display name.. Sadly I do not use exchange server so mailNickname= returns null for me.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now