Getting corrent user - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Getting corrent user

Last post 07-17-2010 06:40 AM by Skarn. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-26-2010 03:12 AM

    Getting corrent user

    I have a big trouble. I need to get the username but i can't create an activexobject. the code that i'm using is:
    Sub XDocument_OnLoad(eventObj)
    Dim wsh
    Dim un
    wsh = CreateObject("WScript.Network")
    un = wsh.UserName
    XDocument.DOM.selectSingleNode("//my:campiPersonali/my:user").text = un

    end sub

    Any sugestion?
    Filed under: , ,
  • 05-26-2010 03:47 AM In reply to

    Why not use InfoPath's userName() function?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-26-2010 04:01 AM In reply to

    I using Infopath 2003.

  • 05-26-2010 05:04 AM In reply to

    Is your code producing any particular error, or just not working?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-26-2010 05:31 AM In reply to

    Not working, the field is empty.
  • 07-17-2010 06:40 AM In reply to

    • Skarn
    • Top 50 Contributor
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    I had similar problems in my workplace - the Network object would not be created (permission denied when I debugged) but Infopath reports no error when the form was opened - just an empty field.

     I have 2 solutions I used - get user to enter their login name into a field - then use the 'IsCurrentUser' function of Infopath to validate that what they put in really is their user name - don't forget to put the domain name for your workplace at the beginning for the 'IsCurrentUser' function.

     The other way was I had an SQL server with a 'view/stored procedure' which had only the 'SUSER' variable as a value. By referencing this view as a secondary datasource and retrieving the values when the form opens - I immediately make the current username available to the form in the secondary datasource field. If you have an SQL database you can use in this way - I think this is the nicest method.

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