Textfield expression. Conditional expression.

0
Hi!

I want to use conditional expression in a textfield expression.
Can I use something like this in a textfield expression?

if $F{Field}="k" then "g"
else $F{Field}


Thanks you in advance.
grotero's picture
Joined: Aug 21 2006 - 5:33pm
Last seen: 12 years 7 months ago

I guess you can write something like below in "Text Field Expression"

 

$F{field}.equals("k")? "g" : $F{field}

 

sanamworld10 - 2 years 2 months ago

5 Answers:

0
$F{field}.equals("k") ? "g" : $F{field}
bklawans's picture
710
Joined: Jul 6 2006 - 1:21pm
Last seen: 1 year 11 months ago
0
bklawans wrote:
$F{field}.equals("k") ? "g" : $F{field}



sir can we use multiple if else in this what u hav repiled ie: $F{field}.equals("k") ? "g" : $F{field}
deepti's picture
4
Joined: Sep 10 2006 - 5:15pm
Last seen: 12 years 6 months ago
0
bklawans wrote:
$F{field}.equals("k") ? "g" : $F{field}



sir can we use multiple if else in this what u hav repiled ie: $F{field}.equals("k") ? "g" : $F{field}
deepti's picture
4
Joined: Sep 10 2006 - 5:15pm
Last seen: 12 years 6 months ago
0

what if I don't want else then ?

 

I am getting an error if I have it  ($F{TR}!=43 ?$F{Product}) What should be the extact syntax

vsoneta's picture
63
Joined: Feb 4 2009 - 5:50am
Last seen: 10 years 1 month ago
0

This is standard Java "In Line" IF THEN ELSE Statement

The syntax is

IF Condition ? Eval to TRUE : Eval to FALSE

The key parts are the "?" and the ":" Question Mark after the Boolean condition. Colon between the TRUE/FALSE results.

You can also nest these statements together eg

IF Condition1 ? Result 1 TRUE : IF Condition 2 ? Result 2 TRUE : Result 3 FALSE

In anser to your Question you need ELSE! add : and a False result.

$F{TR}!=43?$F{Product}:F${TR}

You may need to structure your Logic to account for BOTH true and false results.

Luck!

walmillard's picture
Joined: Jul 30 2006 - 11:53am
Last seen: 12 years 7 months ago
Feedback
randomness