Expand my Community achievements bar.

SOLVED

LiveCycle Newbie: Validate Before Printing Form

Avatar

Level 1

I have a form created in Adobe Acrobat Pro that I have brought into LiveCycle to add print and emails buttons to. However, I need a specific functionality added to the standard "Print" button. It is a legal form that has required fields and the client needs to fill in all the required fields on the form BEFORE printing and signing it. We have had problems in the past with clients not filling in all the required fields before sending it back to them. So, I need to somehow make the print button check to make sure all the required fields are filled in and send a warning message and/or prevent printing if all the required fields are not filled in. Is there a way to do this?

I am using LiveCycle Designer ES 8.2 and I am VERY new to this program so the simpler the solution the better.

Thanks in advance for the help!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi

I have now created a form for this example as the best way to explain to people.

You are correct you can do it within the same button (my knowledge and skills have developed somewhat since the orignal post)

Here is a link to the page where the example can be found.

http://www.dubdubdubdesigns.co.uk/livecycle/formprinting.html

If you have any questions just ask

Regards

Graahm

View solution in original post

33 Replies

Avatar

Former Community Member

Hi Graham,

One more question, now that I have the form working. Is there a way for me to edit the error message that appears if some of the required fields have been left blank?

Thanks,

Joanie

Avatar

Level 3

Graham,

This script has worked well for me in the past, but now I have a checkbox (hirebox) that when checked, pops up another field (hiredate) which must be filled before printing will be allowed.  Here's the script I have applied to the Print button:

form1.#subform[0].PrintButton1::click - (JavaScript, client)

if((hirebox.rawValue == 1) & (startdate.rawValue == null)){

                xfa.host.messageBox("Oh-sorry!  You must enter a start date at the top of this form to be able to print.")}

else{

                PrintButton1.execEvent("click")}

The problem I have now is that the Print button doesn't work otherwise (as in when it is not necessary to check the "hirebox" checkbox).

Oh, and you may need to know also, here's the script I have applied to "hirebox":

form1.#subform[0].hirebox::change - (JavaScript, client)

if

(hirebox.rawValue==1)

    {startdate.presence = "visible"}

else

    {startdate.presence = "hidden"}

Where have I gone wrong?

As always, thanks~

Avatar

Former Community Member

I have made a dynamic submit button which works great for what i need but using this submit button doesn't validate my required fields.

This is the script i have used in mouseup event, using javascript

var cToAddr = "909@gideons.org";

var cCCAddr = RegionalDirector.rawValue;

var cSubLine = "909 Camp Visitation Report-" + xfa.resolveNode("#subform[0].#subform[7].Country").rawValue; var cBody = "Thank you for submitting your 909 report.\n" + "Save a copy for your records";

event.target.mailDoc({

          bUI: true,

          cTo: cToAddr,

          cCc: cCCAddr,

          cSubject: cSubLine,

          cMsg: cBody

});

Is it possible to script this button to check required fields and show a message box like you did for the print form button above?

Thanks

Avatar

Level 1

I have created an example which I have posted on the below link

http://www.dubdubdubdesigns.co.uk/livecycle/examples/button%20click%20with%20form%20validation.pdf

Its quite simple-

- set the fields on your form as user entered - required fields,

- set up your required fields form actions in the form properties section.

- surround your script with a if (form1.execValidation()) { YOUR SCRIPT

GOES HERE }

Any problems let me know

Avatar

Former Community Member

Thank you for replying.

Do if put this script on my submit button?

I am very new at this and don’t understand it all so please bear with me?

Would it look like this?

if (myfield.execValidation())

{

var cToAddr = "909@gideons.org";

var cCCAddr = RegionalDirector.rawValue;

var cSubLine = "909 Camp Visitation Report-" + xfa.resolveNode("#subform[0].#subform[7].Country").rawValue; var cBody = "Thank you for submitting your 909 report.\n" + "Save a copy for your records";

event.target.mailDoc({

bUI: true,

cTo: cToAddr,

cCc: cCCAddr,

cSubject: cSubLine,

cMsg: cBody

});

Avatar

Level 1

Hi

No Problem, we all have to start somewhere.

Yes you would just wrap your existing code in the "if" statement as you

have shown. However, its not so much myfield but the entire form you are

performing the execValidation code on (by default the entire form is called

form1 e.g. form1.execValidation()), you can see this name at the top of the

tree structure in the hierarchical view within Livecycle.

Don't forget you also need to set any fields you wish to be mandatory as a

required field in the Object View, Value Tab

One final thing to configure is the Form Validation settings in the Form

Validation Tab in the form properties. Here you can configure the form

validation responses to invalid forms. Set this to your own preference.

You access form properties via menu File-> Form Properties

Hope this helps.....

Avatar

Former Community Member

You helped me greatly last week and was wondering if you could help me with another question or point me in the right direction.

My submit button works and the validation formula you gave me.

But I have another email address that I would like to be copied and not sure how to script it. I have a field that will be populated with the email address only if other fields are filled out.

So this email address will not always be populated.

How to add this to my script.

For a reminder here is my script.

if (form1.execValidate())

{var cToAddr = "909@gideons.org";

var cCCAddr = RegionalDirector.rawValue

var cSubLine = xfa.resolveNode("#subform[0].#subform[7].CampName").rawValue + ", " + xfa.resolveNode("#subform[0].#subform[7].Country").rawValue + " 909 Camp Visitation Report"; var cBody = "Thank you for submitting your 909 report.\n" + "Save a copy for your records";

event.target.mailDoc({

bUI: true,

cTo: cToAddr,

cCc: cCCAddr,

cSubject: cSubLine,

cMsg: cBody

});}

Thank you in advance.

Avatar

Level 1

The code to add if an email exists is in red. The cc address field used a

semicolon separated list of email addresses, so you can add as many as you

wish using semicolon between each.

if (form1.execValidate())

{var cToAddr = "909@gideons.org";

var cCCAddr = RegionalDirector.rawValue

if (otheremailfield.rawValue != null)

{

cCCAddr += ";" + otheremailfield.rawValue;

}

var cSubLine = xfa.resolveNode("#subform[0].#subform[7].CampName").rawValue

+ ", " + xfa.resolveNode("#subform[0].#subform[7].Country").rawValue + "

909 Camp Visitation Report"; var cBody = "Thank you for submitting your 909

report.\n" + "Save a copy for your records";

event.target.mailDoc();}

Avatar

Former Community Member

Is it possible to add another cc using the code if an email exist?

If so, where do I put it with in the bracket?

Thanks again.

Avatar

Level 1

Hi, you just copy the if statement again below the other and rename the

field to look at.

if (form1.execValidate())

{

var cToAddr = "909@gideons.org";

var cCCAddr = RegionalDirector.rawValue

if (otheremailfield.rawValue != null)

{

cCCAddr += ";" + otheremailfield.rawValue;

}

if (otheremailfield2.rawValue != null)

{

cCCAddr += ";" + otheremailfield2.rawValue;

}

var cSubLine = xfa.resolveNode("#subform[0].#subform[7].CampName").rawValue

+ ", " + xfa.resolveNode("#subform[0].#subform[7].Country").rawValue + "

909 Camp Visitation Report"; var cBody = "Thank you for submitting your 909

report.\n" + "Save a copy for your records";

event.target.mailDoc();

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----