0

I am checking a stream of data in Pentaho Data Integration and am using some Javascript. Certain fields may have one asterisk as the value. So I have:

if (Workgroup = "*") {
   summary_level = "A";
} else {
   summary_level = "W";
}

All values are getting set to "A", even fields where the value is not "*". I have tried:

Workgroup = /\\*/
Workgroup = /\*/

I know I have to escape it, just not sure how I have supposed to write it as a regular expression.

mzy
  • 1,754
  • 2
  • 20
  • 36
urbanmojo
  • 737
  • 3
  • 12
  • 21

1 Answers1

3

You are assigning, not comparing. What you want is if(Workgroup == "*"), the double = means is equal to.

This is the reason why a few programmers write it the other way, if("*" = Workgroup) would result in an obvious error, you cant overwrite a constant string.

TJHeuvel
  • 12,403
  • 4
  • 37
  • 46