Using a MouseUp script attached to a button, I am trying to write a script to open a specific folder from which the user would select an existing fdf file to import.
Presumably this would include employing importAnFDF(). Using importAnFDF()with no cPath specified works OK, if you are happy navigating to the correct folder, but that extra step of navigating to the correct folder is what I want to avoid.
I can't name a specific file to import in the cPath parameter because the user needs to select the file from among several saved fdf files in the target folder.
Also, the path to the folder would be set by the user (i.e., entered in another text field that will remain saved & unchanged from customer to customer), and therefore I want to accomplish this using a variable to identify the text field holding the cPath.
Here is what I tried unsuccessfully:
/*variable 'agents' identifies the field holding the cPath I want to access. For sake of discussion the path is /C/1Data/1MDF_AgentsSellers */
var agents = this.getField("txt.P1.Path.Database.SellerAgents").value
this.importAnFDF(+agents + "/*.fdf")
this.importAnFDF();
with no parameters. The path and name cannot be specified separately. The user has to manually browse the file system to find the input file. And if you did know the exact name and location, this code could not be run from inside a document script. File system operations in Acrobat JavaScript are privileged, they require a trusted context.
Also, it looks like your code is written for a LiveCycle form SOM path? If this is a LiveCycle form an FDF file won't do you much good, you'll need to use an XDP or XML file. There is an import function in the XFA scripting reference that will need to be used.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script