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

Multiple Attachment Boxes

Anonymous
Not applicable

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
christopherf635
Level 1
Level 1

sp215,

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

Anonymous
Not applicable

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

radzmar
Level 10
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?

Anonymous
Not applicable

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