- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 10:16 AM
I am trying to create a switch case condition on workflow for a variable with type as lookup select box.
But it's not getting the correct value from that lookup table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2023 10:42 AM
From the wf_activity_definition record for the Switch activity:
Keep in mind:
*The Switch activity works when the selected variable or field is a type of choice list , so that the Switch activity uses all the choices as possible transition paths.
*You can use service catalog variables as the selected 'Variable'.
*ServiceNow recommends only selecting choice list or reference type fields in the 'Variable' or 'Field' activity variables.
So a Lookup Select Box type variable is not supported with this activity, and as you discovered, does not detect the values. You could try to manually add a Condition for each value - just use the syntax:
activity.result == 'value'
in the Condition field
If the Switch doesn't detect the Lookup Select Box value and follow the correct condition/path as the workflow is executing, another option is to use a Run Script activity setting the activity.result for each value
if (current.variables.var_name == 'value1') {
activity.result = 'value1';
} else if (current.variables.var_name == 'value2') {
activity.result = 'value2';
}...
, then add the same Conditions to this activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2023 10:42 AM
From the wf_activity_definition record for the Switch activity:
Keep in mind:
*The Switch activity works when the selected variable or field is a type of choice list , so that the Switch activity uses all the choices as possible transition paths.
*You can use service catalog variables as the selected 'Variable'.
*ServiceNow recommends only selecting choice list or reference type fields in the 'Variable' or 'Field' activity variables.
So a Lookup Select Box type variable is not supported with this activity, and as you discovered, does not detect the values. You could try to manually add a Condition for each value - just use the syntax:
activity.result == 'value'
in the Condition field
If the Switch doesn't detect the Lookup Select Box value and follow the correct condition/path as the workflow is executing, another option is to use a Run Script activity setting the activity.result for each value
if (current.variables.var_name == 'value1') {
activity.result = 'value1';
} else if (current.variables.var_name == 'value2') {
activity.result = 'value2';
}...
, then add the same Conditions to this activity