- 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 12:13 PM
You will need to do something similar to this.
****Loop inside the list collector field and create task.*********
var myString = current.variables.c_item.toString();
var mySplitResult = myString.split(",");
for (i = 0; i < mySplitResult.length; i++){
var taskCi = new GlideRecord("task_ci");
taskCi.initialize();
taskCi.ci_item = mySplitResult[i];
taskCi.task = current.sys_id;
taskCi.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 12:27 PM
Before I get into the coding part, what table is the list collector variable on?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 12:36 PM
For List Collector Variable I have used a custom table named u_software having 6 records as Software name - A,B,C,D,E and Other.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 12:56 PM
Thanks a lot Guys for such prompt replies I just starting learning scripting in SNOW so looking forward for support from you all.....
This is what i understood from the discussion above :
var list= current.variables.software.toString(); //to fetch values from list which are in format(A,B,C)
var resultsplit= list.split(","); // to split the values based on comma
now tell how to fire APPROVAL based on selected value
A -------> X User
B--------> Y User
C--------> Z User
whats Next ???

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2016 01:04 PM
You don't have any specific conditions on whom to send when a value is selected in the list collector? Because what you have now is just hard coding like if A go to user X