Hello,
New to the forum and also new to LiveCycle Designer. Am attempting to create a form that when opened, would autopopulate the user's id into a text box and can't seem to find out how to do it. Can anyone help me out?
Thanks
Angie
Hello,
New to the forum and also new to LiveCycle Designer. Am attempting to create a form that when opened, would autopopulate the user's id into a text box and can't seem to find out how to do it. Can anyone help me out?
Thanks
Angie
As documented in Adobe's Acrobat JavaScripting Manual, there are security restrictions with respect to the "identity" object. Those restrictions prevent one from directly accessing the "identity" object from a form field. You can access the properties from a folder level JavaScript. The following script when placed in Acrobat's application JavaScript folder will create and initialize application level variables that be accessed by any PDF opened by Acrobat:
// Folder level script to create an application level variables for the "identity" objects properties
var Identity = new Array();
Identity.Corporation = identity.corporation;
Identity.Email = identity.email;
Identity.LoginName = identity.loginName;
Identity.Name = identity.name;
// or
var Identity = new Array();
for (i in identity)
Identity.i = identity.i;
One can then add the following document level or field level javaScript to initialize fields within the PDF to the value of the application level variables:
this.getField("loginName").value = Identity.LoginName;
this.getField("name").value = Identity.Name;
this.getField("by").value = "By: ";
this.getField("by").value += Identity.Name;
With version 7.0 or above, you can use a trusted function located as a document level script to retrieve the information:
trustedIdentity = app.trustedFunction( function (sProperty) {
var iProperty = "";
app.beginPriv(); // explicitly raise privilege
iProperty = identity[sProperty];
app.endPriv();
return iProperty;
})
One can then add the following document level or field level javaScript to initialize fields within the PDF to the value of the application level variables:
this.getField("loginName").value = trustedIdentity("loginName");
this.getField("name").value = trustedIdentity("name");
this.getField("by").value = "By: ";
this.getField("by").value += trustedIdentity("name");
You can find the folders for application folder JavaScripts with:
app.getPath("app","javascript");
app.getPath("user","javascript");
George Kaiser