4 Replies Latest reply on Oct 15, 2010 7:35 AM by gkaiseril

    Auto Populate Text Field With Users Windows Logon Username

    sthompson86 Level 1

      Can anyone tell me how to acheive the following, I want a text field in my form to be automatically populated with the users windows user name.

       

      I have found a reply "Define a new Request.Server variable of REMOTE_USER - This should show DOMAIN\USERNAME"

       

      What script/s should i use on the forum and put where?

      Thanks in advance.

       

      Steven Thompson

      Sydney, Australia

        • 1. Re: Auto Populate Text Field With Users Windows Logon Username
          try67 MVP & Adobe Community Professional

          Place this code as the field's custom calculation script:

          event.value = identity.loginName;

          1 person found this helpful
          • 2. Re: Auto Populate Text Field With Users Windows Logon Username
            gkaiseril MVP & Adobe Community Professional

            You may find a security restriction on access the 'identity' object is only accessible during batch, console and application initialization events to protect the privacy of the user. In which case you will need to create an application folder level script to capture the needed data upon the initialization of Acrobat or Reader.

             

            // application variable to hold the properties of the identity object
            var Identity = new Array();
            // loop through the properties of the identity object
            for (i in identity) {
            // place each property of the identity object into an element of the same name in the Identity array
            Identity[i] = identity[i];
            // console.println(i +": " + Identity[i])
            }

            1 person found this helpful
            • 3. Re: Auto Populate Text Field With Users Windows Logon Username
              sthompson86 Level 1

              Thanks for the replies guys i ahve tried both scripts but my form is still blank.

               

              Do any of you have a blank pdf template with jsut the script mentioned that i can look at and use that works?

               

              Could also be security issues preventing from the previous scripts not working as i am using government facilities.

               

              Thanks in advance,

               

              Steven.

              • 4. Re: Auto Populate Text Field With Users Windows Logon Username
                gkaiseril MVP & Adobe Community Professional

                First you need to place the code I provided in a special Acrobat application level folder and then restart Acrobat or Reader.

                 

                Entering Folder Level Scripts by Thom Parker

                 

                Then in your form field you can use the following code in the 'custom javascript calculation':

                 

                event.value = Identity.loginName;

                 

                Note the capitalization of the word "Identity".

                 

                The application level script will work with Acrobat forms and LiveCycle Designer forms.

                 

                If you want to use a function, you can use the following code in an application level folder:

                 

                getIdentity = app.trustedFunction( function (cProperty) {
                app.beginPriv();
                cValue = identity[cProperty];
                if(cValue == undefined) { // check for unkown identity property
                app.alert("Unknown identity property: " + cProperty);
                cValue ="";
                } // end if undefined
                return cValue;
                app.endPriv();
                } // end app.trustedFuncton
                ) // end getItentity

                And then in the 'custom calculation script':

                 

                event.value = getIdentity("loginName"); // get the loginName