Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

If-else Javascript statement

$
0
0
Hi All,

I have two columns "strCellphone" and "strPhone". I want to create a new column "Phone" and Copy values from "strCellphone" but if "strCellphone" is empty, I want to copy values from "strPhone". I tried this with JS and it works on a normal editor but on Pentaho, I am not getting results as expected.

Here is my JS snippet:

var phone = strCellphone ;
if (!strCellphone.length){phone = strPhone;}

I have also tried various ways of checking null, empty like this one -> if (!strCellphone.length || strCellphone === ' '){phone = strPhone.getString();}

On Pentaho, The result is always assigned to if "strCellphone" even if it is empty.

Can you tell me what could be the problem? Thanks!

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>