Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Multiple Attachment Boxes

Avatar

Former Community Member

Multiple Attachments.PNG

I have created a sample form with 3 attachment boxes in, they all add attachments fine, but when I open the first attachment in box 1 that opens fine, but when I try to open the attachment in Box 2 it will only open the attachment in Box 1

Code to Open Attachment is:-

try{

var myDoc = event.target;

var sFile = ListBox1.rawValue;

 

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

 

catch(e)

Any help would be appreciated

4 Replies

Avatar

Former Community Member

sp215,

Is this the complete code?  It doesn't look syntactically correct (no closing bracket.)  Have you used the syntax/error checker?

Avatar

Former Community Member

The closing bracket was missing off the screen shot - but the code works perfectly for one attachment box

Avatar

Level 10

Do you use the same script for all 3 Lists?

You may accidenty use var sFile = ListBox1.rawValue; for all of them! have you checked this?

Avatar

Former Community Member

Hi,

This is the script for the adding and opening of the listboxes.

 

Add attachment – Listbox1

 

var myDoc = event.target;

 

var sFile = "myFile" + NumericField1.rawValue;

 

  1. myDoc.importDataObject({cName: sFile});

 

var myDataObject = myDoc.getDataObject(sFile);

 

var sFileName = myDataObject.path;

 

ListBox1.addItem(sFileName,sFile);

 

NumericField1.rawValue = NumericeField1.rawValue + 1;

 

 

Add attachment – Listbox2

 

var myDoc = event.target;

 

var sFile = "myFile" + NumericField2.rawValue;

 

  1. myDoc.importDataObject({cName: sFile});

 

var myDataObject = myDoc.getDataObject(sFile);

 

var sFileName = myDataObject.path;

 

ListBox2.addItem(sFileName,sFile);

 

NumericField2.rawValue = NumericeField2.rawValue + 1;

 

 

Open attachment – Listbox1

 

try{

 

var myDoc = event.target;

 

var sFile = ListBox1.rawValue;

 

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

 

}

 

catch(e)

 

{

 

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

 

}

 

 

Open attachment – Listbox2

 

try{

 

var myDoc = event.target;

 

var sFile = ListBox2.rawValue;

 

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

 

}

 

catch(e)

 

{

 

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

 

}

 

I need to find a way of clearing the list box before opening as it is retaining the 'last' opened document regardless of which listbox it was from

Thanks