Get UserName Code Conversion - InfoPath Dev Sign in | Join | Help in Code InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Code » Get UserName Code Conversion Get UserName Code Conversion Last post 01-24-2007 02:08 PM by Patrick Halstead. 3 replies. Page 1 of 1 (4 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 01-23-2007 06:06 AM brorick Joined on 01-23-2007 Posts 7 Get UserName Code Conversion Reply Contact The following code works perfectly when I use it with a C# Infopathtemplate. I am not familiar with C # and therefore I am limited as towhat else I can do with the form. Can anyone tell me how to convertthe following code to VB script. Thank you in advance.IXMLDOMNode nodeEmployee = thisXDocument.DOM.selectSingleNode("my:myFields/my:employee"); if(nodeEmployee != null) { if(nodeEmployee.text == "") { // if the employee name is blank when we load the form, // populate the employee node with the current user name nodeEmployee.text = System.Environment.UserName; } } 01-23-2007 12:54 PM In reply to Patrick Halstead Joined on 08-08-2006 Posts 5,112 Re: Get UserName Code Conversion Mark as Not AnswerMark as Answer... Reply Contact Hi Brorick and welcome to our forum,This example is in Chapter 2 of my book. Dim name As Stringname = Environment.UserNamethisXDocument.DOM.selectSingleNode("/my:myFields/my:employee").text = name Patrick HalsteadProject Manager at Qdabra 01-24-2007 06:21 AM In reply to brorick Joined on 01-23-2007 Posts 7 Re: Get UserName Code Conversion Mark as Not AnswerMark as Answer... Reply Contact Patrick. Thank you for your help. I searched all over the place for this code on the web. I just recently obtained a copy of the Developing Solutions with Microsoft InfoPath book. At a quick glance it looks like one of the more informative books out of the five I own on InfoPath. I look forward to reading it as I have had all kinds of issues with InfoPath 2003. The Company I work for will continue to use this version for at least several more months. It has possed many challenges for me.For instance, I have an employee SQL table and I am searching for a way to lookup the current user name(Login ID). For example if the current user name(Login ID) is LS123RB then in the OnLoad event I would like to automatically lookup this Login ID in the employee table and autopopulate the employees department name field, manager's name field and so fourth. Can you point me in the direction as to where I can find out how to accomplish this? Your help is greatly appreciated. Thank you. 01-24-2007 02:08 PM In reply to Patrick Halstead Joined on 08-08-2006 Posts 5,112 Re: Get UserName Code Conversion Mark as Not AnswerMark as Answer... Reply Contact Hi again,Thanks for the feedback!We sell an Active Directory Web service http://www.qdabra.com/proddetail.asp?prod=QADWS) that many people use to get user information. Check out this post http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=683) in our forum for some steps on how to query it to get user info. Unfortunately, InfoPath doesn#%92t allow you to query SQL using fields from your form. To programmatically query values from SQL, you will need our Qdabra Database Accelerator http://www.qdabra.com/proddetail.asp?prod=QDBXL1). The Developer version is free. Let us know if we can help you with the installation/configuration.Cheers! Patrick HalsteadProject Manager at Qdabra Page 1 of 1 (4 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.