How to evaluate multiple choice variable in workflow

chrish5
Giga Guru

I have a catalog item variable of type Lookup Select Box called "Applications" that has about 20 choices in its dropdown list.   This variable is pulling its options from a column in a custom table I created.  In my workflow, I've tried using a switch to evaluate this variable, but it won't list the options.  I've used switches in many of my workflows, but they have been for Select Box type variables and never for Lookup Select Box type variables.  Is this not possible?  

 

As a workaround, I tried resorting to the "If" condition in the workflow and going beyone the usual 'yes', 'no' options with the multiple options shown below, but have been unsuccessful in getting this to work.  

 

Looking for any suggestions on getting either my Switch or If condition to work correctly.  Thanks!

 

chrish5_0-1701118611134.png

 

 

 

answer = check();
function check()
{
if(current.variables.application == 'Test 1') {
return 'test 1';
}
if(current.variables.application == 'Test 2') {
return 'test 2';
}
if(current.variables.application == 'Test 3') {
return 'test 3';
}
}

 

 

 

1 ACCEPTED SOLUTION

chrish5
Giga Guru

I ended up being able to do this via the Run Script activity with conditions that match the activity.result. 

 

if(current.variables.application == 'Test 1') {

  activity.result = 'test 1';

}

if(current.variables.application == 'Test 2') {

  activity.result = 'test 2';

}

if(current.variables.application == 'Test 3') {

  activity.result = 'test 3';

}

View solution in original post

6 REPLIES 6

I have confirmed with ServiceNow that Lookup Select Box type is not supported in the switch activity. 

chrish5
Giga Guru

I ended up being able to do this via the Run Script activity with conditions that match the activity.result. 

 

if(current.variables.application == 'Test 1') {

  activity.result = 'test 1';

}

if(current.variables.application == 'Test 2') {

  activity.result = 'test 2';

}

if(current.variables.application == 'Test 3') {

  activity.result = 'test 3';

}