- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 06:10 AM
Hey guys,
I am working on a task in which when I select options from Slushbucket or list collector variable in SR and order it.
then as per selected options Approvals goes to different users??
while searching through the community I tried different Approval Scripts but didn't worked. Please help? ctomasi
I am creating workflow on sc_req_item
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 02:04 PM
In your user approval activity, check the advanced check box and put this script in there
answer=[];
var arr= current.variables.SR.getDisplayValue().split(',');
for(i=0; i<arr.length; i++){
if(arr[i].trim()=='A'){
answer.push(sys_id of user X);
continue;
}
if(arr[i].trim()=='B'){
answer.push(sys_id of user Y);
continue;
}
if(arr[i].trim()=='C'){
answer.push(sys_id of user z);
continue;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 06:17 AM
You may have to create a series of "if" statements that each evaluate for one of the values in the variable list.
if list contains "A", then go one way
If list contains "B", then go another way
I thought you could script a switch activity, but it doesn't look like it.
Reference:
Workflow Concepts - ServiceNow Wiki
Creating a Workflow - ServiceNow Wiki
Using Workflow Activities - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 11:46 AM
ctomasi Hey Chuck my main problem is i am unable to fetch values from LIST COLLECTOR or SLUSH BUCKET value as there is no backend value of these A,B,C,D and E shown in list collector left bucket.
give me some code to get values in workflow so that i can compare it and fire approvals?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 12:05 PM
If your workflow is on the RITM and the variables are on the RITM, then you should have access to the values as
current.variables.variable_name
Have you tried doing some quick debug output in the workflow or testing it in scripts background to ensure you can get at these values?
This may help do some debugging...
Faster Server Side Script Development and Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 12:09 PM
As Chuck mentioned, you can use current.variables.<list_collector> to fetch the values.
FYI, list collector will have sys_IDs as the back end.