These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

use windows login name in textfield

petermaas
Registered: Apr 29 2008
Posts: 8
Answered

Because I couldn't find this in one of the other forums as a topic, this is probably a new one.
When working with Designer, is it possible to define textfields to automatically have the name of the login of Windows?
So, when you log in to Windows, for example as 'peter maas' and you woud open a certain PDF file, that your name would already be filled in.

Which script would be neccessary to have this done?
It would be a nice timesaver for someone who has to fill in dozens of forms each day (beside the auto-completing function of acrobat).

thanks
Peter Maas

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The users login name is stored in the "Identity" object in Acrobat JavaScript, not LiveCycle JS. For obvious security reasons this object cannot typically be accessed from a script in a PDF. So the short answer is no, you cannot create a LiveCycle form that automatically fills in the users name.

It can however be accessed from a trusted folder level script. So for example, you could create an Acrobat toolbar button on your own system that would fill in this data.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

petermaas
Registered: Apr 29 2008
Posts: 8
Okay, Thank you. Then in this case this is where it ends. My customer has started to work in Designer, not Acrobat. Second thing is that the users will be using AdobeReader, not AcrobatPro, to fill in forms ( I suppose that Reader doesn't support custom toolbar buttons).
Thanks for your reply.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Actually, most of the Acrobat JavaScript Model is accessable from the LiveCycle Scripting model, and the entire LiveCycle scripting model is available to Acrobat JavaScript. So there is no conflict here with what you can do.

And, you can place toolbar buttons on Reader from a folder level JavaScript and access the Identy object. So for this, there's no Reader limitation.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

petermaas
Registered: Apr 29 2008
Posts: 8
I found that in several cases the scripts appeared not te be quite exchangeable between Acr-Pro and Designer . But you seem to know more details on this. Could you help me in the solution for this specific case, or does it take a lot of your valuable time?
regards, Peter
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
For the identity item it makes no difference whether one is using Acrobat or Reader or the forms are created in Acrobat or LiveCycle Designer. The issue is the security restrications that strated with version 7 and how to program arount them.

I have found that many AcroForm JavaScript methods or properties work if one uses the "JavaScript" language option in LiveCycle and one writes function independent of field names.

One can define a new folder level variable array which is initialized by the Acrobat/Reader application that will allow a form designed using AcroForms or LiveCycle Designer. In LiveCycle Designer one must use the "JavaScript: option.

// create an application variable to hold the properties of the identity object
var PFIdentity = 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
PFIdentity[i] = identity[i];
}

The calculation script in AcroForms:

event.value = PFIdentity.loginName; // get the loginName

The JavaScript calculation for LiveCycle Designer:

PFIdentity.loginName; // get the loginName

A folder level function to retrieve an identity object property:

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

The calculation script in AcroForms:

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

The JavaScript calculation for LiveCycle Designer:

PFIdentity("loginName"); // get the loginName

I will let your figure out how to tell what version of Acrobat or Reader a user is using so you can provide the appropriate version dependent code for using the function.

George Kaiser