Solved

Get Username for Infopath Form

Posted on 2007-04-03
4
4,698 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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