Expand my Community achievements bar.

SOLVED

How can I check for attachments?

Avatar

Former Community Member

I have check boxes adding attachments to a form.  On clicking a Submit button, I need a script to check for an attachment if the corresponding check box is selected.  Any suggestions?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

you can check the number of attachments the following way:


if (event.target.dataObjects) {


    // When there are attachments


     var o = event.target.dataObjects.length;


    xfa.host.messageBox("There " + (o > 1 ? "are " : "is ") + o + (o > 1 ? " files" : " file") + " attached.");


} else {


  // When there are no attachments


  xfa.host.messageBox("There are no files attached");


}


View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

you can check the number of attachments the following way:


if (event.target.dataObjects) {


    // When there are attachments


     var o = event.target.dataObjects.length;


    xfa.host.messageBox("There " + (o > 1 ? "are " : "is ") + o + (o > 1 ? " files" : " file") + " attached.");


} else {


  // When there are no attachments


  xfa.host.messageBox("There are no files attached");


}


Avatar

Level 5

Hello,

I have a checkbox that should be checked if there are files attached.  I have the following script in the layout:ready event of the checkbox field, but it doesn't work.  I have tried putting form1.execCalculate() in different areas of the form, but nothing seems to work.  The only time the box gets checked is when drop-downs in the form are used.  Any help would be appreciated.


if (event.target.dataObjects) {


  this.rawValue = "1";


}


else {


  this.rawValue = "0";


}