Six Stars

Problem in tMap formula : condition if ... else

Dear experts, 

 

I have an issue with this formula in my tMap :

row2.status == "PRE_TXT" ? 1 : row2.status == "TXT" ? 2 : -1

 

In fact, it's only return -1 whereas I have the values : "PRE_TXT" and "TXT" in my source field. 

 

 Many thanks. Best regards 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Six Stars

Re: Problem in tMap formula : condition if ... else

I've found the solution : 

 

row2.status.equals("PRE_TXT")?1:row2.status.equals("TXT")?2:-1 

Six Stars

Re: Problem in tMap formula : condition if ... else

Removed my post, as I'd made a mistake regarding Java operator precedence. Sorry.

 

Comparing the value of strings using .equals() is guaranteed to work in all cases, and that's specifically what it's designed to do.

3 REPLIES
Six Stars

Re: Problem in tMap formula : condition if ... else

I've found the solution : 

 

row2.status.equals("PRE_TXT")?1:row2.status.equals("TXT")?2:-1 

Six Stars

Re: Problem in tMap formula : condition if ... else

Removed my post, as I'd made a mistake regarding Java operator precedence. Sorry.

 

Comparing the value of strings using .equals() is guaranteed to work in all cases, and that's specifically what it's designed to do.

Six Stars

Re: Problem in tMap formula : condition if ... else

Thank you for these explanations Smiley Happy

 

Best regads