Get UserName Code Conversion - InfoPath Dev
in

InfoPath Dev

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: Previous Next
  • 01-23-2007 06:06 AM

    Get UserName Code Conversion

    The following code works perfectly when I use it with a C# Infopath
    template. I am not familiar with C # and therefore I am limited as to
    what else I can do with the form. Can anyone tell me how to convert
    the 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

    Re: Get UserName Code Conversion

    Hi Brorick and welcome to our forum,
    This example is in Chapter 2 of my book.

    Dim name As String
    name = Environment.UserName
    thisXDocument.DOM.selectSingleNode("/my:myFields/my:employee").text = name
    Patrick Halstead
    Project Manager at Qdabra
  • 01-24-2007 06:21 AM In reply to

    Re: Get UserName Code Conversion

    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

    Re: Get UserName Code Conversion

    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 Halstead
    Project Manager at Qdabra
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.