Expand my Community achievements bar.

SOLVED

Open PDF Attachments

Avatar

Level 3

My form has a repeatable subform that contains both a scripted button for adding attachments and a list box (titled "attachedfile") which displays the attached files.  As the subform is repeated there are more buttons and from which I can add more attachments to their respective list boxes.  The script appears to work like a charm, but if I manually try to view the attachments I'm only able to see the last one.  When I save the PDF, the file names in the list boxes disappear and I'm only able to open the last file I attached.  Here's the script for my attach button, hopefully someone can point out my problem.

var

myDoc = event.target;

var

sFile = "myFile"

myDoc.importDataObject({cName

: sFile});

var

myDataObject = myDoc.getDataObject(sFile);

var

sFileName = myDataObject.path;

sub9.Table20.Row1.attachedfile.addItem(sFileName

, sFile);

-gollum

1 Accepted Solution

Avatar

Correct answer by
Level 10

Preserve scripting changes isn't turned on.

File->Properties->Defaults->Scripting - set "Preserve scripting changes to form when saved" to Automatically.

View solution in original post

4 Replies

Avatar

Level 3

Hmm... It has nothing to do with being repeatable because even if I only have one field for adding attachments, upon saving the file, closing it, then opening it again, only 1 attachment is present; the most recently attached file.  The others disappear.  Why?

-gollum

Avatar

Level 3

Yes, that's the file I used to figure out how to do this scripting in the first place.  I just tested the sample and found that although it doesn't have the problem of losing attachments after the file has been saved and reopened, they no longer appear in the list box.  It looks like I'm dealing with two issues here.  Could you explain to me why Paul's sample doesn't keep the attachments in the list box when it's saved and reopened?  Thanks.

-gollum

Avatar

Correct answer by
Level 10

Preserve scripting changes isn't turned on.

File->Properties->Defaults->Scripting - set "Preserve scripting changes to form when saved" to Automatically.