none
Get the computer name to pre-populate a field on a form

Answers

  • Hi Daddicus,

    Try to use JavaCcript to dynamic assign InfoPath as following:

    function XDocument::OnLoad(eventObj)
    {
        //Create a WScript.Network object, which provides access to the user data
        var objNetwork = new ActiveXObject("WScript.network");
        //Retrieve the ComputerName and write it into the my:ComputerName field
        XDocument.DOM.selectSingleNode("/my:myFields/my:ComputerName").text= objNetwork.ComputerName;
    }
    NOTE: It's only can use for Internet Explorer Browser, Internet Explorer's security settings will affect whether you can create and use the WScript.Network object.

    For more information, please refer to the following link:
    http://blogs.msdn.com/b/timpash/archive/2005/10/17/retrieve-user-name.aspx

    Thanks,
    Lhan Han

    Thursday, April 12, 2012 7:54 AM

All replies

  • Probably, System.Web.HttpContext.Current.Request.UserHostName can help. It gets the DNS name of the remote host. Then you need, somewhere in codebehind, to generate and add javascript, which populates a field on the page with the host name.

    .Net Follower (http://dotnetfollower.com)

    Tuesday, April 10, 2012 8:41 PM
  • Thanks! I'll try that!
    Tuesday, April 10, 2012 9:10 PM
  • I don't know javascript, and I am unfamiliar with the syntax I would use to interrogate that value. Can you point me to a resource that could help me implement this? Google searches haven't turned up anything.

    Thanks!

    Wednesday, April 11, 2012 3:09 PM
  • Hi Daddicus,

    Try to use JavaCcript to dynamic assign InfoPath as following:

    function XDocument::OnLoad(eventObj)
    {
        //Create a WScript.Network object, which provides access to the user data
        var objNetwork = new ActiveXObject("WScript.network");
        //Retrieve the ComputerName and write it into the my:ComputerName field
        XDocument.DOM.selectSingleNode("/my:myFields/my:ComputerName").text= objNetwork.ComputerName;
    }
    NOTE: It's only can use for Internet Explorer Browser, Internet Explorer's security settings will affect whether you can create and use the WScript.Network object.

    For more information, please refer to the following link:
    http://blogs.msdn.com/b/timpash/archive/2005/10/17/retrieve-user-name.aspx

    Thanks,
    Lhan Han

    Thursday, April 12, 2012 7:54 AM