Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Cancelling the save action

Avatar

Level 2

I created a form in AdobeLivecycle Designer ES 8.1. Now on the bottom of this form there is a print, save and clear button, when the print or save button is click a validation that i have written on the click event of the button runs. NOTE (I HAVE NOT USED user required on the fields). This validation checks if certain fields have been selected or has information in them. If the validation returns false a message is displayed to tell the user to enter the required information, the field highlighted and the save or print action cancelled. Now the buttons work perfectly. The problem is if the save diskette/icon or print icon (button that adobe naturally provide to save/print forms) located in adobe is clicked I want my validation to be checked and if failed the save/print request cancelled. Is there a way to do this? If not is there a way to disable them?

P/S As you know If the user decides to close an unsaved form, a question pops up to the user asking if he/she wants to save the document; I want my validation to be done at this point, could this be done?

10 Replies

Avatar

Former Community Member

You can use the prePrint and preSave events to execute your code. These events will run prior to printing or saving no matter which way the user invokes the Print/Save. If your code returns validation issues and you do not want to allow a print or save then use the xfa.event.cancelAction command to cancel the upcoming command. This line of code is dependant upon which event it is triggered with. If it is n a prePrint the the next Print request is cancelled. If it is on a preSave event then the next Save action is cancelled.

Note that this command was added in version 8 (I think) so make sure you test it on all versions that you know your users will use. Previous to this there was no way to cancel the operation.

Paul

Avatar

Level 2

Thanks for the reply...I figured it has something to do with the prePrint/preSave events, but on what field or moreover where will I put my code to do this, meaning you are only allowed to enter codefor the prePrint/preSave events ontextfields, checkboxes etc. could i just put it on any textfield and it is guaranteed that the event will be called wen the print or save button that adobe provides is clicked.  To continue whenever I am entering this xfa.event.cancelAction, u know when you enter xfa. (livecycle gives you some options to select from a dropdown list) when I reach xfa.event. (there is no cancelAction event and I am working with Adobe Livecycle 8.1)

Thanks in advance

Avatar

Former Community Member

You can put it on any object as they will all be checked when printing or saving is done. As a general rule (to make it easier to maintain I always put code that is generic to the form (not to a specific field) on the root node (usually form1). This makes it easier for someone to find if they need to look at the form.

The feature you are referring to is called Object Assist. I am using version 8.2 of Designer and it is there. The feature may stil be there but the Object Assist may not have been updated. You can simply type it in and try it.

Paul

Avatar

Level 2

Well I tried putting it on a textfield object ...no result the print action was still called and not cancelled...where is the on the root node? how do u access the code information for this?

Avatar

Former Community Member

Well it seems that it was only implemented in version 9. I changed my target version to 9 and it worked .....if I leave it at 8.1 then I get a javascript error.

There was no way to cancel it in those versions.

One thing you can do is to hide your print button (make it invisible). Then create a regular button (make it look like a print button to the user) and have your validation code on the button. If the validations succed then your code can push the real print button using  - buttonName.execEvent("click").

This will work if they use that print mechanism, but if the user hits Ctrl-P or hits Print from the menus then your code will not get executed.

Paul

Avatar

Level 2

oh ok well thanks for the help...is there a way to disable these print buttons that adobe provides though?

Norman Sandcroft

Avatar

Former Community Member

Yes but that is more trouble than what it is worth. You woudl have to create a js file and distribute it to each user. Put it in the proper location then when the form loads the menu options woudl be gone.....for all PDFs ...not just yours.

Paul

Avatar

Level 2

hey I just downloaded the Adobe Acrobat 9 trial version for testing to see if your solution worked...Using Livecycle es 8.2 which is bundled with the product I do see the cancelAction under xfa.event; however could you send me an example of how you use this method to cancel saving on the pre save button? code examples will help?

Avatar

Level 2

I also did some reading on my own else where and this is what I found

http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/common/html/wwhelp.htm?conte...

which states that it doesn't applies to the preSave event.

Is this true? I tested the cancel action on the prePrint event  and it did cancel it but when tried on the presave it failed.

Here is the code I used:

xfa.event.cancelAction = 1;

Thanks for ur assistance.

Avatar

Former Community Member

The help is a little ambiguous. The description at the top does not mention the preSave but the Values section does. My guess is that the command originally cancelled the Save but it was removed (for whatever reason) and the docs were not updated fully. I tried it and was not able to cancel a Save so I am guessing that it was removed and you cannot use that.

Paul