Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

How to remove the warning "do you want to save changes to investigation.pdf before closing"

Avatar

Level 2

Issue: To remove the warning "do you want to save changes to investigation.pdf before closing"

I have created a XFA pdf file(using LC Designer 8.2) to display this issue

I am not able to attached the PDF. Without attaching the pdf it would be difficult to explain.

click event js:

function activateUser() {
  var PDFVersion=xfa.host.variation+xfa.host.version;
  xfa.host.messageBox("button click event registered");
  xfa.form.form1.sendForm.welcomeMsg.presence = "invisible";
  xfa.form.form1.sendForm.successMsg.presence = "visible";
  event.target.dirty=false;
};

docReady event js:

function displayInfo(){
var res =xfa.host.variation;//Added this line to display the successMsg
//xfa.host.messageBox("docReady event registered");
xfa.form.form1.sendForm.welcomeMsg.presence = "visible";
xfa.form.form1.sendForm.successMsg.presence = "invisible";
};

docClose event js:

xfa.host.messageBox("docClose event registered");
event.target.dirty=false;

Steps to get the warning:
1) Open the attached pdf using Acrobat Professional.
2) Click the Confirm Enrollment" button
3) Now close the document & the acrobat gives a warning "do you want to save changes to investigation.pdf before closing"

Summary of the XFA pdf:
It has two text fileds. On docReady event field A is made visisble & field B is made invisible.
On button click event the field A is made invisisble & field B is made visible.
On closing the pdf it should not throw this warning message.

My Efforts:
1) Found a property in adobe js docs.
       event.target.dirty=false;
It doesn't solve the problem.
2) I tried to put this logic in almost all the events listed in designer but I am not able to resolve the issue.

Please help me resolve this issue.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Changing the visual appearance is dirtying the form, even before any data is actually inputted into the form. I have seen this before.

I think the docClose event is too late to have the dirty/requiresFullSave script. preSave won't work either, as this will fire after the warning dialogue is displayed.

For a test, I would suggest putting the dirty/requiresFullSave script in the layout:ready event. Not the most efficient, but it should fire after the visibility of the messages is changed.

This might be of interest: http://cookbooks.adobe.com/post_How_often_events_fire_and_their_sequence-16547.html

Niall

View solution in original post

5 Replies

Avatar

Level 10

Hi,

The API reference also states:

Acrobat1.png

You may also need to set the requiresFullSave to false as well.

Good luck,

Niall

Avatar

Level 2

I tried putting the below 2 lines of code at the end of button click event & docClose event.

      event.target.dirty=false;
      event.target.requiresFullSave=false;

It still gives the warning.

Also I tried to found out the line of code which is making the pdf dirty.

  xfa.host.messageBox("is doc dirty (before displayInfo's visible-invisible work): " + event.target.dirty);
  xfa.form.form1.sendForm.welcomeMsg.presence = "visible";
  xfa.form.form1.sendForm.successMsg.presence = "invisible";
  xfa.host.messageBox("is doc dirty (after displayInfo's visible-invisible work): " + event.target.dirty);

The doc got dirty when the successMsg field is made invisible.

Problem I am trying to solve is:

     To display a welcome message before user action and after user action wants to display a success message.

     I follwed the visible & invisible approach & it wokred but gives me a warning on doc close.(Highly imp to avoid it)

Is there any other approach I could follow here.

Avatar

Correct answer by
Level 10

Hi,

Changing the visual appearance is dirtying the form, even before any data is actually inputted into the form. I have seen this before.

I think the docClose event is too late to have the dirty/requiresFullSave script. preSave won't work either, as this will fire after the warning dialogue is displayed.

For a test, I would suggest putting the dirty/requiresFullSave script in the layout:ready event. Not the most efficient, but it should fire after the visibility of the messages is changed.

This might be of interest: http://cookbooks.adobe.com/post_How_often_events_fire_and_their_sequence-16547.html

Niall

Avatar

Level 2

ThnxsNiall O'Donovan for your answer.

Yesterday I put the same script in all the registered events in designer except layoutReady.

By the time I reached to formReadyEvent I lost faith in this approach & just left it.

I really appreciate ur help & many thanks to u.

Avatar

Level 10

Glad you got it working.

Just a word of caution: if users are inputting data into your form as well, then the script will mean that they will not be prompted to save this data either.

It would be worth testing before deployment.

Good luck,

Niall