On Load event - Computername and Username

J

Jamie

I would like a onload function that populates the COMPUTERS name and the
USERS userid
I currenlty do this with the below function but have some issues with it.
One: When I'm in Design and click Preview Form it works (receive ActiveX
confirmation and populates data) when I double click the xsn file it does
not work (no ActiveX confirmation and does not populate data).
Two: it requires the user to say yes to an activeX message is there a way to
avoid this?

==========================================================
function XDocument::OnLoad(event)
{

// Avoid DOM updates when the document has been digitally signed.
if (XDocument.IsSigned)
return;

// Initialize the date
initializeNodeValue("/iss:issue/iss:createdDate",
getDateString()+"T"+getTimeString());

//Create a WScript.Network object, which provides access to the user
data
var objNetwork = new ActiveXObject("WScript.network");

//Retrieve the UserName and write it into the my:UserName field
XDocument.DOM.selectSingleNode("/iss:issue/my:UserName").text =
objNetwork.UserName;

//Retrieve the ComputerName and write it into the my:ComputerName field
XDocument.DOM.selectSingleNode("/iss:issue/my:ComputerName").text =
objNetwork.ComputerName;

}
 
L

LarryFarrell

We just got user information on a project. Had to use a webservice
that queried Active Directory User object for information. I imagine
that you can do the same for computer name (though the User Object
doesn't have it). You end up with a much prettier name for the user,
usually having the First and Last names available to you depending on
how AD was implimented.

Let me know if you find a way to get the computer name.

--Larry--
 
J

Jamie

Larry,
What I do in the original post gives me the login name and the Computer
name. The problem is the difference between how the form is loaded. I have
read a few items on the form being trusted and think this may be my problem.
I just don't understand why it works in the original situation.

But again like I said the code I posted gives you the ComputerName and the
UserID.

Jamie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

getcurrentuser 1
Get User Name in a Form 2
'null' is null or not an object 3
Error: Infopath 0
Several problems 1

Top