Attachment open action is not working properly

pizush

18-08-2018

Hi

I am trying to create a dynamic form for my firm in Livecycle designer ES4 where user will add attachment in PDF and send it to other user. I am using below code (thanks to Paul for sharing in https://forums.adobe.com/thread/665139).

 Code used in my form:
//For add button:
var myDoc = event.target;
var sFile = "myFile" + NumericField1.rawValue;
myDoc.importDataObject({cName: sFile});
var myDataObject = myDoc.getDataObject(sFile);
var sFileName = myDataObject.path;
ListBox1.addItem(sFileName,sFile);
NumericField1.rawValue = NumericField1.rawValue + 1;
//For delete button:
try{
var myDoc = event.target;
var sFile = ListBox1.rawValue;
app.alert(sFile);
myDoc.removeDataObject(sFile);
ListBox1.deleteItem(ListBox1.selectedIndex);
/*
var myRemoveObject = event.target;
var a = myRemoveObject.getField("Untitled[0].#subform[0].ListBox1[0]");
a.deleteItemAt(); // delete current item, and...
a.currentValueIndices = 0;
*/
NumericField1.rawValue = NumericField1.rawValue - 1;
}
catch(e)
{
app.alert("Error in removing document");
}
xfa.layout.relayout();
//For Open button:
try{
var myDoc = event.target;
var sFile = ListBox3.rawValue;
myDoc.exportDataObject({ cName: sFile, nLaunch: 2 });
}
catch(e)
{
app.alert("There are no files to open");
}
 

Using Paul's sample, I can add a file, but when I save, close, and open the sample, the file is no longer in the listbox.  It is now in the attachments (paper clip in side panel).  I am not using the "Show Attachment Names + Launch/Size" button in my file.

As per Paul's reply, I checked under the File/Form Properties/Run-time tab there is a "Preserve scripting changes to form when saved" radiobutton. It is already set to automatically.

Is there any way to make it populate the box with what is in the attachments area?  Because end user isn't going to know about the attachment or how to get there/know that something is there. That's why I want the attachments to appear in the listbox when they open the form.

image1.png

Regards

Accepted Solutions (1)

Accepted Solutions (1)

_Bruce_Robertson

MVP

23-08-2018

So, you are saying if you just save it locally and then re-open it the listbox values are retained, but if you email to someone within your organisation the listbox values are not retained, but the attachments attached to the form?

I guess you could look at reloading the listbox from the attachments in the form, but I would be more interested in what the mail system is doing ... and how ... and whatelse it is changing

Answers (11)

Answers (11)

pizush

26-08-2018

Hi

Your re-populating listbox input drive me to search the forum and found this thread Update Number of Attachments Field where Mouslander advised to use formatted value. Thanks to both of you.

Rgds

pizush

26-08-2018

Hi Bruce

I changed NumericField1.rawValue to NumericField1.formattedValue in add button and  object locale from default to English (USA) for all buttons. This time listbox values were retained in mail recipient's computer. Would you pls share why this happened as I have no idea.

Rgds

pizush

23-08-2018

"So, you are saying if you just save it locally and then re-open it the listbox values are retained, but if you email to someone within your organisation the listbox values are not retained, but the attachments attached to the form?"

---- yes, you are right.

Would you please help me with some code in reloading the listbox from the attachments in the form.

And for mail system, what should I check?

Rgds

_Bruce_Robertson

MVP

21-08-2018

Hi,

There's a lot going on with this form, but if I add an attachment save the form and then re-open it the listbox retains the file name.

At what point does the filename get lost?

Bruce

_Bruce_Robertson

MVP

20-08-2018

Hi,

It should work for a dynamic form as well, do you have the same thing happening with Paul's sample?  I don't see anything in your initialize scripts.

I am happy to have a look at your form if you are able to share and try it in my environment.

But, maybe you could just re-populate the listbox in the form:ready event.

Bruce

pizush

20-08-2018

Hi Bruce

Sorry, I forgot to share one issue.

In our firm, we use internal outlook mail service. When a person add attachment in his/her PC, attachment name is populating in listbox. But it is not populating in recipients PC. I converted my form to static PDF and this time listbox is okay with attachment name in recipient's PC.

If I use static form then searchable dropdown facility is lost.(Thanks for sharing a great feature in your blog, Adobe LiveCycle Designer Cookbooks by BR001: Updated: Drop-Down List Control with auto-complete (Sea... ).

Thanks

pizush

20-08-2018

Thanks for reply.

There is one code in initialize event in

form1::initialize - (JavaScript, client)

xfa.host.messageBox("This document requires Adode Acrobat Pro 9 or higher or Adobe Acrobat Pro DC to get full feature of the form. Click OK to continue.", "Software Version Requirement", 2);

if (!app.runtimeHighlight){

     app.runtimeHighlight = true;

}

I have two drop down box (userSelection & prodfacility) and one text box (prodlocation) that has below code

form1.page1.userSelection::docReady - (JavaScript, client)

if(this.rawValue == null)

{

this.rawValue = "";

}

form1.page1.prodfacility::docReady - (JavaScript, client)

if(this.rawValue == null)

{

this.rawValue = "";

}

form1.page1.prodlocation::docReady - (JavaScript, client)

this.rawValue = prodfacility.rawValue;

Do I need to remove above codes so that attachment name could be saved when I save the form?

Regards

_Bruce_Robertson

MVP

19-08-2018

Should be as simple as that, setting the preserve scripting in Paul's sample works for me.  Do you have any other code that runs on opening the form?