Solved

Get Username for Infopath Form

Posted on 2007-04-03
4
4,675 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
ID: 18845531
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
ID: 18860371
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
ID: 18871524
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
ID: 19028868
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My experience with Windows 10 over a one year period and suggestions for smooth operation
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now