Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Understanding how file upload script inside a subform works with LiveCycle

Avatar

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
zyrusc13762308
Level 2

18-07-2018

Good afternoon;

I have a form that I'm working on that requires a file upload script. I incorporated it based on the sample on this thread (https://forums.adobe.com/message/1976160#1976160). The form has hidden subforms so there's some heirarchy going on but I'm not able to figure out how to factor that into the script so the form allows the user to find the file and attach it, etc.

How would I modify the script in the sample for subforms? What am I missing?

I appreciate your help.

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
zyrusc13762308
Level 2

27-07-2018

LOL, check this out...

All that work only to find out that the attach button won't work on Reader Extended forms without the LC extension...

[sigh]

Avatar

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
zyrusc13762308
Level 2

Likes

4 likes

Total Posts

38 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
zyrusc13762308
Level 2

27-07-2018

Hello, thank you for your response.

I was able to get a slightly better understanding based off combining this thread (https://forums.adobe.com/thread/1235441) with this one (https://forums.adobe.com/message/10056473). Again; might make perfect sense for some but I'm still growing in coding. I was just happy to get it to work. Now, it could certainly be coded better, but for now, my client seems happy with the solution. As time permits (and if projects EVER slow down enough to allow), I'll try and get a better understanding of what's going on in the code and modify it so that it incorporates some more validation, control, etc.

Here's what I used for each of the buttons for attaching, opening, and removing file(s):

Attach button:

// attach file to form

var myDoc = event.target;

var sFile = "MyAttachedFile";

myDoc.importDataObject({cName: sFile});

var myDataObject = myDoc.getDataObject(sFile);

var sFileName = myDataObject.path;

Main.sfAttachmentRequest.attachmentsList.addItem(sFileName,sFile);

Open button:

// open attachment in separate instance

try{

var myDoc = event.target;

var sFile = Main.sfAttachmentRequest.attachmentsList.rawValue;

myDoc.exportDataObject({ cName: sFile, nLaunch: 2 });

} catch(e) {

app.alert("There are no files to open");

}

Remove button:

// remove attachment from listbox

var myDoc = event.target;

var sFile = Main.sfAttachmentRequest.attachmentsList.rawValue;

app.alert("You have removed the highlighted file from the form",1);

myDoc.removeDataObject(sFile);

Main.sfAttachmentRequest.attachmentsList.deleteItem(Main.sfAttachmentRequest.attachmentsList.selectedIndex);

var myRemoveObject = event.target;

var a = myRemoveObject.getField("Main.sfAttachmentRequest.attachmentsList");

a.deleteItemAt(); // delete current item, and...

a.currentValueIndices = 0;

xfa.layout.relayout();

The example I built this from uses a list box to display the attached files which is great if attaching multiple files, but I'd like to figure out how to modify it for only attaching/displaying single files, as well. Probably a simple change.

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

395 likes

Total Posts

2,686 posts

Correct Reply

491 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

23-07-2018

Do you want to add an attachment to your file via scriptings? Where do you want to use the fiorm finally – Adobe Reader or Acrobat? For the former you'll need a LiveCycle server with the Reader Extensions module to enable this function in the form, for the latter, you can use the importDataObject() method i.e.

event.target.importDataObject({cName: "Image.jpeg"});