Else if condition on Workflow Editor

alexcharleswort
Tera Expert

Hi all, 

I am trying to create a customized if activity in the workflow but it keeps returning 'no' instead of the values that I designate in the script. 

find_real_file.png

This is the script I have in the activity:

answer = ifScript();

function ifScript() {
if(current.variables.travel_vehicle_pickup_cc1 == 'ad0425b4dcad9200283d117488b17b73'){
return 'kansas';
} else if(current.variables.travel_vehicle_pickup_cc1 == '2f03911c89dc8500e4382dea5d5a1c3e'){
return 'omaha';
} else if(current.variables.travel_vehicle_pickup_cc1 == 'a8577cb090acc50067b602c75c7ec67f'){
return 'texas';
}
}

 

 and this is what my condition script looks like:

find_real_file.png

 

What am i missing?? I know that i have the values correct in the if script because I pulled it out and put it in another if script that just returned 'yes' or 'no' and that worked fine. 

What am I missing? I swear I try this once every 6 months or so but never got it to work and just made workarounds. 

Any help would be greatly appreciated!

- Alex

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

An if workflow activity can only return a Yes or No whereas I think you need to use a Switch activity. The Switch activity performs a check to determine if the value of a passed field or variable is equivalent to one of several case values. When you add the Switch to your workflow and configure it, it will build the possible results for you.

View solution in original post

3 REPLIES 3

Michael Fry1
Kilo Patron

An if workflow activity can only return a Yes or No whereas I think you need to use a Switch activity. The Switch activity performs a check to determine if the value of a passed field or variable is equivalent to one of several case values. When you add the Switch to your workflow and configure it, it will build the possible results for you.

Hi,

I have implemented switch case for a similar scenario, but my switch is reading only "ELSE = TRUE" 

Please find attached screenshot and requesting your inputs to fix this

Harsh Vardhan
Giga Patron

answer will always accept yes or no.

why don't you save the result in workflow.scratchpad or you can use switch activity .

 

adding one blog will help you..

 

https://community.servicenow.com/community?id=community_blog&sys_id=d1fde22ddbd0dbc01dcaf3231f961912