Hello,
I found the following code example in order to get the username the user who opened the form:
function XDocument::OnLoad(eventObj) {
//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("/my:meineFelder/my:Username").text = objNetwork.UserName;
}
For testing I created a simple InfoPath form as you can see though the template.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:Code:-myXSD-2009-02-17T15-22-18" href="manifest.xsf" solutionVersion="1.0.0.1" productVersion="12.0.0" PIVersion="1.0.0.0" ?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?>
<my:meineFelder xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-02-17T15:22:18">
<my:Username></my:Username>
</my:meineFelder>
When I open the preview I get the following message:
A runtime error occured.
...
Automation server can't create object
File: script.js
What did I do wrong? How do I have to set up the form options?
Thank you very much indeed for helping me.