Solved

Get Username for Infopath Form

Posted on 2007-04-03
4
4,677 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

774 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