Jump to content

Who to use varialbe (boolean) in Jasper Book as Print When Expression


thiel.walter

Recommended Posts

Hello together!

For you information, this is our framework:
Our company want to use Jaspersoft Studio to create formulars like a contract or offer document. The enduser fill up some fields on a webpage and the values will written in the database. Then the printout of the contract or offer document over the webpage use a xml-file. In Jaspersoft Studio we use this xml-File with xPath, too. There we have a Jasper Book and at least two Jasper Reports. We design the formulars on the Jasper Report jrxml-Files and the build japser-files are on the Jasper Book. With a parameter "DataSource" in the Jasper Book we bring togehter later the xml-Values and the Jasper Reports. In the Jasper Book we also controll the order and visibility with the Print When-Expression.

My Question:
I want use a variable for Print When in the Jasper Book. So I have created a variable "Fehlerseite" in the Jasper Book.
converted-file.png.f18c09610a359416e1bf96a3edea665c.png

Because I tested the expression "$F{AS1_STAMM.ANREDE_ID}==0 && $F{KLK.VRR}!=0 && $F{AS2_STAMM.NAME}==null" within a Text Field on a Jasper Report, I know that I get a boolean value "true".

converted-file.png.e587da69ba309c0cdbf166ef4a586bc5.png

But when I use the expression $V{Fehlerseite} in Print When for one page of the Jasper Book, I get the result "Document is Empty".

converted-file.png.7cde1d1221b87b4cb393629ec517ca81.png

I don't understand this. When I use the complete expression in Print When then it works. But I don't want to use the full expression every time.

I hope you can help me.

Thank you Walter

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Try this:

In the "Initial Value Expression" use

$F{AS1_STAMM.ANREDE_ID}==0 && $F{KLK.VRR}!=0 && $F{AS2_STAMM.NAME}==null ? true : false

 

When use expression, she test the expression, but not have return value, she is a simple test. If you want a return, must place the returns in the expression.

Then use your $V{variable}

 

 

Link to comment
Share on other sites

Good morning tiago,

it doesn't work. It set the values true and false in quotes.

$F{AS1_STAMM.ANREDE_ID}==0 && $F{KLK.VRR}!=0 && $F{AS2_STAMM.NAME}==null ? "true" : "false"

And think it works, but I forget to replace the value "true" out off the print when field :-/
Why it works with the expression in the print when field or when I use only the value "true" in the print when field, but doesn't work when I set the variable $V{Fehlerseite}?

Walter

 

 

Link to comment
Share on other sites

  • 3 weeks later...

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...