?
Solved

Get Username for Infopath Form

Posted on 2007-04-03
4
Medium Priority
?
4,703 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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 simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

719 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