Username from registry into Textfield - InfoPath Dev
in

InfoPath Dev

Username from registry into Textfield

Last post 04-16-2009 05:52 AM by partysan. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-15-2009 07:28 AM

    Username from registry into Textfield

     Hello!

    I need  a solution to get the username value from the registry into a infopath textfield.(name of the textfield "field1").

    I work with Infopath 2003, thereforce i cannot use the "username" function.

    How I modify the following code.


    Sub CTRL3_5_OnClick(eventObj)

          Dim Username

          set wshshell = createobject("Wscript.shell")

          Const strBaseKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name"

          Username = wshshell.regread(strbasekey)

          msgbox (Username)

    Approximately (but i dont know the correct syntax) : myFields/my:field1").text = Username 

    End Sub

     

    Best regards

    Philipp

     

     

     

  • 04-15-2009 10:49 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Username from registry into Textfield

    Hi,

     

    You can use below code to get the username.

    thisXDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Buyers/d:WorkOrders/@ALCOUN").text = System.Environment.UserName;

    And also verify below code to get user name without writing code.

    http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

     

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 04-16-2009 01:07 AM In reply to

    Re: Username from registry into Textfield

     Hello!

     

    Im not sure but the Code that you' ve been send me is written in c#, i need vbs (see above) ?

    The second solution is not possible for me.

     

    Best Regards

    Philipp

     

     

  • 04-16-2009 05:52 AM In reply to

    Re: Username from registry into Textfield

     Hello!

     

    I found the correct code:

    I think it is a easy way to get the Username into a Textfield:

     

    Dim Username set wshshell = createobject("Wscript.shell")

    Const strBaseKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name"

    Username = wshshell.regread(strbasekey)

    XDocument.Dom.SelectSingleNode("my:meineFelder/my:Feld1").text = Username 

     

    Regards

    Philipp

     

     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.