Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Attachment open action is not working properly

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

12 Replies

Avatar

Level 10

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?

Avatar

Level 2

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

Avatar

Level 2

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

Avatar

Level 10

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

Avatar

Level 2

Hi

I tried with paul's sample and same thing happened.

I am sharing my form for your view

Deviation Report Form.pdf - Google Drive

Rgds

Avatar

Level 10

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

Avatar

Level 2

Hi,

List box doesn't retain file name when recipients open the file after receiving it by internal mail.

Avatar

Correct answer by
Level 10

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

Avatar

Level 2

"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

Avatar

Level 2

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

Avatar

Level 10

Hi, Not sure I can help, I was not able to reproduce your problem and I can't see how those changes would have had any impact.

Avatar

Level 2

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