IF Condition in workflow always returns yes

Christopher Dan
Kilo Contributor

I am try to write a IF condition advanced script that will be yes if some locations but no if it is the rest. This will allow me to assign it to the correct assignment group in the workflow. The location variable is a reference field so im not sure if that my issue or not. Please tell me why my script keeps returning yes every time. See script below.

function ifScript() {

  if (current.variables.cmn_location != 'Olofstrom' || current.variables.cmn_location != 'Bielsko-Biala' || current.variables.cmn_location != 'Gothenburg' || current.variables.cmn_location != 'Forsheda')

  return 'yes';

  else

  return 'no';

17 REPLIES 17

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Chris,



Small change. Replace current.variables.cmn_location with current.variables.cmn_location.getDisplayValue()




current.variables.cmn_location; //Will give the sys_id


current.variables.cmn_location.getDisplayValue(); //Will give the display value




Hence the final script will be


function ifScript() {


  if (current.variables.cmn_location.getDisplayValue() != 'Olofstrom' || current.variables.cmn_location.getDisplayValue() != 'Bielsko-Biala' || current.variables.cmn_location.getDisplayValue() != 'Gothenburg' || current.variables.cmn_location != 'Forsheda')


  return 'yes';


  else


  return 'no';




Pradeep,



Thanks for the suggestion but it is still returning yes every time, is there something im missing?


Can you paste the complete script here as is.


Victor Ruiz
Tera Guru

Why not use the condition builder?



conditionbuilder.jpg