How to use a SWITCH into a workflow with Yes/No variable type from a catalog item ?

thomasnoret
Kilo Contributor

Hi guys,  

when using a variable like a "Select Box" I can retrieve with a SWITCH into a workflow all the choices available...

But while using this SWITCH function with a Yes / No variable type, it does not list automatically Yes, No as possibilities... Do you know why ?

Do I need to add a  condition by right clicking on the swith and putting a condition called "yes" and another one "no"  ?

OR should I need to create select box with Yes & No as choices ?

 

thanks a lot !

1 ACCEPTED SOLUTION

Can you please try with below script.



answer = ifScript();


function ifScript(){


if(current.variables.Corefa_UCM_BudgetOwner == 'Yes')


  return 'yes' ;


return 'no';


}


View solution in original post

16 REPLIES 16

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

if you only has yes & no, why not just use the if-statement activity?


Sure but then I need to put a script into the "IF" activity ?


Hi Thomas,



Yes you will need to have script in if activity



answer = ifScript();



function ifScript(){


if(current.variables.<variable_name> == 'yes')


  return 'yes' ;


return 'no' ;



}



Instead you can use switch condition easily: just select the variable and select the path it should follow based on variable value



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi, unfortunately this did not work... it seems it did not find yes so it went through no.



do i need to put Capitals ?



find_real_file.png