These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Required fields and Print Button functionality

Boscott
Registered: Apr 21 2008
Posts: 8

I have created 20 order forms in LiveCycle Designer 8.1 with several required fields on each form. User rights are enabled in Adobe Reader. The forms will not prevent users from printing or saving incomplete documents when the "Print Form" button is selected. Previous version of program used to prompt users with a message box that the form could not be saved or printed until all required fields were completed. Adobe tells me I need a javascript for the Print Form button. I'm wondering if this is true and/or what that code might be?

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
A JavaScript for a custom print button might be:

if (Form1.Page1.Formfield1.rawValue == null ||Form1.Page1.Formfield2.rawValue == null  ||Form1.Page1.Formfield3.rawValue == null ||...Form1.Page1.Formfieldx.rawValue == null){app.alert({cMsg:"Please fill out the mandatory fields.",cTitle: "More information requiered", nIcon: 1, nType: 0} );}else{xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);}

But, this will only work for a button directly placed into the form, the build-in print button/fuction of Reader/Acrobat will not be affected by this script and still allow printing on every time.
The same is for the save/save as...-function.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

Boscott
Registered: Apr 21 2008
Posts: 8
Thank you for the proposed script. I don't seem to be able to make it work by adding a new button. I'm at a loss. I need to finish this project for my client, but I'm feeling frustrated with Adobe for omitting a standard function that they sold to me as the main reason to get me to upgrade in the first place.
ozsupra
Registered: May 17 2009
Posts: 22
radzmar wrote:
A JavaScript for a custom print button might be:
if (Form1.Page1.Formfield1.rawValue == null ||Form1.Page1.Formfield2.rawValue == null  ||Form1.Page1.Formfield3.rawValue == null ||...Form1.Page1.Formfieldx.rawValue == null){app.alert({cMsg:"Please fill out the mandatory fields.",cTitle: "More information requiered", nIcon: 1, nType: 0} );}else{xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);}

But, this will only work for a button directly placed into the form, the build-in print button/fuction of Reader/Acrobat will not be affected by this script and still allow printing on every time.
The same is for the save/save as...-function.
Interesting that we seem to be having a similar issue.
The above advice is only partially correct. The above code works great for field checking, however will not print the PDF if PDF security has been envoked and printing turned off.
This is stange. Most apps allow code to overright basic settings.
Boscott
Registered: Apr 21 2008
Posts: 8
I have found several other similar types of required fields and Print Button requests in the forum, but all have very different answers. I just tried another suggested script to no avail. Very frustrating!