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.

Trying to hide text fields that the user has left blank when printing

Avatar

Former Community Member
Hi,



I'm trying to hide optional text fields that the user has left blank when printing a document.



I've tried the following JavaScript on the Preprint option to no avail:



if {this.rawValue == " "} this.presence = "hidden";



if {this.rawValue == Null} this.presence = "hidden";



if {this.rawValue == Null()} this.presence = "hidden";



Any ideas?



Thanks!



Andi
6 Replies

Avatar

Former Community Member
Hello,



try this. Maybe it's the solution:



if (this.rawValue == "")

{field.presence = "hidden"};

Avatar

Former Community Member
That didn't work either. Any other ideas?



Thanks!



Andi

Avatar

Former Community Member
Instead of making the pressence of the field hidden, try setting the relevant property to -print (this says that you do not want the field on when you print). Don't forget to set it back (+print) on the post print event.

Avatar

Former Community Member
The problem is that I want to print the field if the user has placed a value in it.



I want to hide the field if the user has left the field blank to save on space on the page.

Avatar

Former Community Member
in your script your syntax looks wrong. It should be:



if (this.rawValue == null) { this.presence = "hidden"}



The other problem is that you say if (this.rawValue == " ") the problem with this is that there is a blank char there so it will prove false. You should change it to read: if (this.rawValue == "" )



I hope that helps

Avatar

Former Community Member
I've had a lot of problems with the Pre-Print event. I have a script where I have to reverse all of my colors on the dark form I am creating to print mostly white. I couldn't get it to work in Pre-Print. Are you using a print button on the form? If you are try calling the script to make the fields hidden in the button click, before the script to execute the print.



Also, when you use the term "null", be sure that it is all lowercase. I don't think JavaScript will recognize "Null". It has to be "null".