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.

Hidden text fields and prePrint event

Avatar

Level 2
My form has a set of text fields whose values I concatenate using the prePrint event into a hidden text field that appears only on print. The problem is that if the user enters new text into one of the data collection text fields but does not tab out of the field before printing, that new text does not appear on the printed copy. Adobe's scripting basics doc actually warns about using the prePrint event to do this. Has anyone found a good work around? I thought about forcing a save before printing.
7 Replies

Avatar

Former Community Member
Michael,

You can always put a print button on your form that does the concatenation on the click event.

Avatar

Level 2
That's a good idea and thanks for your input Kyle. If I put a Print button on my form, will that deactivate the File>Print menu option in Reader? If not, then someone is bound to use it and I'm back to my problem.



Also, I've chosen to not include basic functions such as print, save, and email (available on the Reader menu or tool bars) as buttons on my forms, except for buttons with specific functions such as "Email Personnel". I don't mind rethinking my design decisions if I need to though.

Avatar

Former Community Member
Michael,

True you will be in the same boat if the user ends up selecting print from the file options rather than using the print button on the form. Putting a print button on your form will not disable the print option from the file menu. I know it is possible to disable that option from the file menu, but I have never done it.



You can also play around with the full or change events for your input fields. You can set the change event to concantonate the values in the hidden field. This way each time the user makes any kind of change to the input fields the hidden field's value is updated. You can then control the visibility of this hidden field through the presence option under the Object/Field tab. All fields that you wish to concatonate will need to have the same change or full event javascript that would look something like:



hiddenField.rawValue = field1.rawValue + " " + field2.rawValue;



The hidden field should then have a presence of Visible(Print Only). This way this field will only display when ever a preprint event is called (either from selecting print from the file menu, through scripting, or via a print button on the form), and will go back to being hidden after the postprint event is called.

Avatar

Level 2
Hey Kyle, thanks for the response. It's my understanding from the scripting Help that the Change event fires on every keystroke. I wouldn't want to concatenate into my hidden field on this event would I? I'm working with multi-line text fields with no length limits.



I've been trying to get the setFocus method to work. It appears that Adobe does this after a print anyway. If I print a form, then press tab after the form refreshes, I'm at the first field in the tab sequence.



So in the prePrint event of my first field in the tab sequence, I'm using the setFocus method. However, it ain't workin'. Why am I doing this? The scripting Help says this about setFocus: If any form object has the input focus, the focus is removed from that object and any pending edits in that object are committed. So you can see I'm trying to force updates on any text field that might have the focus.



Problem is the help available is not that good. I've found two formats:

xfa.host.setFocus ("TextField1.somExpression") -LiveCycle Designer Scripting Basics

xfa.host.setFocus(xfa.form.form1.TextField1); -LiveCycle scripting Help



Note that I'm using JavaScript.

Avatar

Former Community Member
Michael,

I know what you're trying to do with the set focus, and I had tried to go down that path before as well. Unfortunately I've never been able to call the setFocus on a prePrint event. While it makes logical sense that if you set focus on some field as the first step in your preprint process that the exit event would be called on the input field, and your concatenation would work because the user would no longer be in the input field. Unfortunately this does not work. You really are limited by this, but again you can get around all this by using a print button on your form. One way to help cope with the fact that a user can still select print from the menu options, is to tie a hidden print flag field to the print button. This flag would only be set to true if the print button is pressed (set in the click event). In the preprint event you can then check for this flag. If it is set to false (print button was not pressed) then you could display a message box to the user telling them that certain functionality requires them to print using the print button on the form. This way you are at least telling the user that the printed form will not look correct/have the right information unless the print button is used. At this point you're really just trying to find a workaround solution for the limitation of a field having focus on a preprint event, and not having the data that was entered in that field acknowledged by the system. Hope this helps, or gives you an idea of how to overcome this limitation for your situation.

Avatar

Level 2
Correction: I've been playing with one of my forms that doesn't do anything on prePrint and it looks like the focus stays on the last field entered after print.

Avatar

Level 2
Well dang. :) I thought that the setFocus without the parameter should work, but no deal. If setFocus does not work on the prePrint event, then it should be listed in the doc with the other events it won't work with. Looks like I may have to go with the Print button. Great tip on the print flag. Thanks so much for your help Kyle.