Skip to main content
Participant
April 21, 2023
Question

Check attachments have been added before submitting.

  • April 21, 2023
  • 1 reply
  • 1199 views

Hi everyone, 

I am new to adobe and also new to Javascript and learning as i go, so any help would be fantastic. The situation is i have created a form to be sent out to customers and filled in with data required. I have a warning that will pop up when clicking the submit button which will ask to fill in specified fields that may have been missed - this works great. 

 

I have also added tick boxes asking if a picture can be provided (as an attachment in the PDF), once this box is ticked i have managed to get it to show a button, once this button is pressed it opens windows file explorer and the attachment panel in adobe.

what i am now trying to add is. If the tick box that asks if you can provide a picture (attachment) is ticked. when the submit button is pressed it will check if the PDF has had any attachments added before sending.

 

I have had the form returned to me a couple of times where a customer has ticked they can provide a picture. But not attached one. 

Thanks, 

James.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
April 21, 2023

In the Acrobat JavaScript model, attachements are called "DataObjects".   There is a "dataObjects" property of the document object. If it is null, then there are no attachments. 

 

For example:

if(this.dataObjects){

     ... perform submit ...

}else

    app.alert(" Please provide an attachment");

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 24, 2023

Brilliant, Thank you!