Switch case statement in a script

jasleen3
Kilo Contributor

Hi,

My script is running fine if I am using "if statement", but if i use switch it's not working at all.

find_real_file.png

19 REPLIES 19

Chuck Tomasi
Tera Patron

Hi Jasleen,



Just for "safety" sake, try converting the country field value to a string and add a debug statement before you use it to double check.



var country = current.requested_for.country.toString();


gs.log('country = ' + country);



your switch statement looks fine at a glance.


I am having the same issue. My output (CSV) in this case is showing the output of 'ship_to_state' instead of 'ShipToStreet' indicating that there should have been a match on the switch.

find_real_file.png

Hi Chuck,

Is it possible to get date automatically in the "Next Update Due" field based on Severity field.

As the "Next Update Due" field is Date Type but Severity field is String Type.

 

find_real_file.png

anurag92
Kilo Sage

Getting the logs fine?



Just to be double sure, can you do this:


swicth(country.toString())