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

Folder level script - reusable functions

cl5792
Registered: Jul 17 2008
Posts: 53
Answered

Within a folder level script I have a function that populates a field in the PDF which works fine when called from VB for that PDF. I have been having trouble getting the right syntax to change it so that I can use this function in other PDFs where the field would have a different reference. How can I change this function to make it useful for any PDF by passing a field name?

function InsertFirstName(sFirstName)
{
this.xfa.form.Root.Page6.Section10.FirstName.rawValue = sFirstName;
}

Thank you

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I have found that Acrobat's AcroForm JavaScript syntax will always work with either a form created by using Acrobat or LiveCycle Designer. Your syntax is using the LiveCycle Designer JavaScript syntax and most likely will only work with forms created by LiveCycle Designer.

George Kaiser

cl5792
Registered: Jul 17 2008
Posts: 53
I am sorry, I did not state that I am using Livecycle Designer.

What I need help with is changing the syntax of the function to be able to use it for any PDF that has a "FirstName" field. However, it may be on a different page or subform. The function works fine for the specific PDF that has the Firstname on the page/subform in the script, but I need to be able to use it on other PDFs.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Because of the differences between the XML forms of LiveCycle Designer and AcroForms of Acrobat in the naming and referencing of fields, I would not perform any operation that requires accessing a field name in a folder level function. I use only objects and values as passed and returned parameters.

I look at solution using Acrobat's 'identity' object which has a property of 'loginName' and an optional user specified 'name' property as part of a folder level script to get this information.

George Kaiser

cl5792
Registered: Jul 17 2008
Posts: 53
I was able to use a folder level function as a global function by passing the fully qualified reference:

function InsertFieldValue(sFieldValue, cFieldName)
{
var oFld = this.xfa.resolveNode(cFieldName);
oFld.rawValue = sFieldValue;
}

Passing the field name as:

"xfa[0].form[0].Root[0].Page1[0].LastName[0]"

This worked beautifully from within VB to pre-populate a PDF from a recordset. I can use this to populate any field in a PDF as long as I know the full reference.