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).
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