File attachment is not opening – Not Allowed Error

tonydaes

10-09-2018

Hi,

this is my first attempt to prepare a dynamic form in Livecycle Designer ES4. In this form, there is an option to add and view attachment. As I have little experience in javascript coding, I went to the adobe forum and found a very good example posted by Bruce in https://forums.adobe.com/thread/2517255. Thanks to Bruce.

I made some adjustment in the code and my final code looks like below-

//Code for add button

form1.page1.ImportDataObject::click - (JavaScript, client)

// Get Import Name

var cName = AttachName.rawValue;

// Test for empty value

if(!/^\s*$/.test(cName))

{// Do Import

   try{

     var bRtn = event.target.importDataObject(cName);

     if(bRtn)

     {

        var cDesc = AttachDesc.rawValue;

        if(!/^\s*$/.test(cName))

        {

            var oAtt = event.target.getDataObject(cName);

            oAtt.description = cDesc;

        }

        app.alert("File Attachment Successfully Imported",3);

     }

     else

        app.alert("Unable to import File Attachment",0);

   }catch(e){

     app.alert("An Error Occured while Importing the File Attachment:\n\n" + e);

   }

}

else

   app.alert("Attachment name must be non-empty");

//code for dropdown list

form1.page1.AttachNameSel::preOpen - (JavaScript, client)

this.rawValue = null;

this.clearItems();

var a = event.target.dataObjects;

if (a !== null) {

for (var i = 0; i < a.length; i++) {

this.addItem(a[i].name);

}

}

//code for open button

form1.page1.ExportAttach::click - (JavaScript, client)

//code for export attachment button

var cName = AttachNameSel.rawValue;

//var nAction = ExportAction.rawValue;

    try{

    event.target.exportDataObject({cName:cName, nLaunch:2});

    } catch(e) {

      app.alert("An Error Occured while Exporting the File Attachment: " + cName + "\n\n" + e);

    }

With the above code, I can attach file successfully. But my problem is that when I want to open file attachment in Acrobat Pro XI, it is showing below error instead of opening the file. This error is showing independent of file attachment type (I tried attaching doc, txt and pdf file).

image1.png

BeIow is the screenshot link of security of acrobat Pro XI.

https://drive.google.com/file/d/1gJw62602GNgoGBbQcluiwF79ShfoOqhF/view?usp=sharing

https://drive.google.com/file/d/1Q_3RGcHU_0nsyZIM9lOnuGPeFXCAFxno/view?usp=sharing

Here is the link of my fileDropdown Attachment.pdf - Google Drive

Any help from anyone in the community would be greatly appreciated.

Thanks

Tony

Message was edited by: Tony Daes file link attachment changed

Accepted Solutions (0)

Answers (2)

Answers (2)

tonydaes

23-09-2018

Hi Radzmar,

Thanks for your reply.

My file GPD is a .doc file. I checked the code in Acrobat Pro DC and attachments are opening without any problem. Now I am using below code so that acrobat pro XI user can open file by selecting from navigation panel.

if((app.viewerVersion)<12){event.target.viewState = {overViewMode:7};}

else {

//code for export attachment button

var cName = AttachNameSel.rawValue;

//var nAction = ExportAction.rawValue;

    try{

    event.target.exportDataObject({cName:cName, nLaunch:2});

    } catch(e) {

      app.alert("An Error Occured while Exporting the File Attachment: " + cName + "\n\n" + e);

    }

}

Thanks

radzmar

MVP

15-09-2018

The script is fine, the problem at you end seems to be the attached file itself. Acrobat exports only a handful of file types (PDF, JPG, PNG …), all others a blocked for security reasons, so noone simply could run an evil executable attached to a PDF. You screenshot states that your file "GPD" doesn't have any file extensions, so Acrobat of course blocks it.

Attachments — Acrobat Application Security Guide