Jump to content
JasperReports Library 7.0 is now available ×

conditional expression if name field is empty


Go to solution Solved by pawe84,

Recommended Posts

I have in my report a text field where the name and address is shown in this way:

$F{Customer Name 1} +"\n"+
$F{Customer Name  2} +"\n"+
$F{Address} +"\n"+"\n"+
$F{Country}

 

How I can remove a blank line when $F{Customer Name  2} is blank? Inside the database the field is not null it's just empty/blank.

I tried the following condition but it seems that it doesn't work.

In my report preview I still got the blank line if Customer Name 2 is blank.

 

$F{Customer Name 2} ==" "  ?
	 $F{Customer Name 1} +"\n"+
	 $F{Address} +"\n"+"\n"+
     $F{Country} 
	:
 	$F{Customer Name 1} +"\n"+
	$F{Customer Name  2} +"\n"+
	$F{Address} +"\n"+"\n"+
	$F{Country}

 

I already setup the text field "Remove Line When Blank" but this also doesn't work.

Even to check field is not null doesn't work

$F{Customer Name 2} == null  ?

Any ideas what I did wrong?

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

I solved it now.

At first I created two variables and then used the following condition:

!($F{Sell-to Customer Name 2} == null || $F{Sell-to Customer Name 2}.trim().isEmpty())?$V{addr_displ2} :$V{addr_displ1}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...