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

Trying to get importTextData to work

paulwesson
Registered: Jan 19 2010
Posts: 3

I created a simple form based on a tab delimited text file. The form has 2 input fields "Task" and "Level_Required".

I simply just want to load the values from the text file into these fields when I click a button.

My button "mouseUp" event looks like this:

event.target.importTextData("tasks.txt",0);

var task = this.getField("Task");
var lr = this.getField("Level_Required");

this.frmTasks.Task[0] = task.value;
this.frmTasks.Level_Required[0] = lr.value;

When I run it the debugger comes back with:

Acrobat JavaScript Debugger Functions Version 9.0
Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0
Exception in line 1 of function top_level, script XFA:frmProgressCard[0]:frmTasks[0]:cmdLoadLists[0]:mouseUp

Can anyone shed some light on this for me?

My Product Information:
LiveCycle Designer, Windows
paulwesson
Registered: Jan 19 2010
Posts: 3
In order to get this to work I had to put the importTextData into a trusted folder level script. ie.

c:\program files\adobe\acrobat 9.0\acrobat\javascripts\config.js

TrustedImportTextData = app.trustedFunction( function ( oDoc, fileName, row ) {
app.beginPriv();

var Result = oDoc.importTextData(fileName, row);

app.endPriv();
return Result;
});

Now if I could only get the "getField" to work!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
I'm not sure getField is a LC function...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

pwesson
Registered: Jan 29 2010
Posts: 2
I was able to get the code part set up and working properly but now have it a snag with the actual import of the file. Every example I've ever found says that first row in your tabbed delimited text file should contain the column names. What they don't tend to explain further is that they have to match that layout in your form.

You can't simply have "first_name" as your column header. It has to be something like subForm[0].form1[0].table1[0].row1[0].first_name[0] or something like that, I haven't quite got that figured out yet.

I get the error message "Invalid Row" when I try to import my file.

I have an example I've put on my website that you can download. I'll try and write out the web address without getting banned this time!

www dot s89760191 dot onlinehome dot us slash LiveCycle slash ImportTextFiles dot zip

Hopefully someone can shed some light on this.

1. Designed using LiveCycle Designer ES
2. Being run in Acrobat Pro 9

Thanks!
Paul
pwesson
Registered: Jan 29 2010
Posts: 2
Just tested this under Acorobat Pro 8 and it worked fine.

What is different in 9 that causes it not to work?