text expression question..

 I want to get the value of a field to show based on whether the values of two other fields match. I wrote a text expression I thought might work but no luck yet.

Any ideas?

Here is the expression as it stands riight now.

It's not erroring out, it just doesn't bring back the desired value.

 

Thanks

Code:
(($F{PARTTRACKINGID}== $F{TRACKINGTEXTTAGID})?"getValue($F{TRACKINGTEXTINFO})":"")</td></tr></tbody></table>
viking79's picture
186
Joined: Jan 5 2012 - 11:40am
Last seen: 11 years 8 months ago

6 Answers:

Hi,

I think you don't need getValue function. To compare the fields both have to be the same type. If these are integer type try setting this:

(($F{PARTTRACKINGID} == $F{TRACKINGTEXTTAGID})? $F{TRACKINGTEXTINFO}: "")

Otherwise, if they are string type you have to do a small modification:

(($F{PARTTRACKINGID}.equals($F{TRACKINGTEXTTAGID}))? $F{TRACKINGTEXTINFO}: "")

Hope this helps.

Regards.



Post Edited by augarte at 01/27/2012 14:56
augarte's picture
6525
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 3 days ago

 Hi, thanks for the response.

What I would like to do is if ParttrackingID is equal to 5, I need it to print the value of TrackingTextInfo in the box.

That's were I'm really hung up.

I have several different sections of the report that need fulled, and ParttrackingID value is what dictates what goes in each one but the actual value I want shown is in the trackingtextinfo, if that makes sense.

Any suggestions?

Thanks and take care

 

viking79's picture
186
Joined: Jan 5 2012 - 11:40am
Last seen: 11 years 8 months ago

And which is the type of your fields? This is very important when writing expressions

augarte's picture
6525
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 3 days ago

Parttrackingid is int

Trackingtextinfo is varchar

Sorry about that, probably should have mentioned that



Post Edited by viking79 at 01/27/2012 15:38
viking79's picture
186
Joined: Jan 5 2012 - 11:40am
Last seen: 11 years 8 months ago

Don't worry :-)

I guess PARTTRACKINGID is 'Java.lang.Integer' cause 'int' is not in the available types. So in this case I think this should work:

(($F{PARTTRACKINGID}.intValue() == 5)? $F{TRACKINGTEXTINFO}: "")

If you want to compare it with TRACKINGTEXTTAGID you should change to:

(($F{PARTTRACKINGID].intValue() == $F{TRACKINGTEXTTAGID}.intValue()) ? $F{TRACKINGTEXTINFO} : "")

Note that the field your are editing the expression has to be 'Java.lang.String' type.

Hope this helps.

Regards.

augarte's picture
6525
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 3 days ago
Hey thanks for all your help, still not getting the info we need, but I think is has to do with how we are trying to join the tables, rather than the text expression. I think once we figure that out, I can use some of the ideas you had to get the text boxes to fill out.

Anyways, thanks again :)
viking79's picture
186
Joined: Jan 5 2012 - 11:40am
Last seen: 11 years 8 months ago
Feedback