Saturday, January 10, 2004

A fairly common task within an InfoPath form is to add the currently logged on user name (ie. network name) to a field in a form. Actually, this is fairly easy to do with a few lines of code and the WScript object.

 

// Load the originator name - this the person that opened the form

var objNetwork = new ActiveXObject("WScript.network");

XDocument.DOM.selectSingleNode("/approver:documentinformation/approver:

Originator").text = objNetwork.UserName;

 

If you wanted to perform this when the form opened you would add it to the OnLoad event.


11:21:23 PM