- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 09:30 AM
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.
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:
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 09:48 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 09:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2022 09:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 09:51 AM
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