We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Passing list collector variable value in Workflow

baqar rizvi
Mega Expert

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

find_real_file.png

I am creating workflow on sc_req_item

find_real_file.png

1 ACCEPTED SOLUTION

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;


}


}


View solution in original post

12 REPLIES 12

yes somewhat its hard code i want to know how it works ?? for X Y Z i can put sysid of the users. rest please tell??


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;


}


}


thanks a ton brother....   that worked.



I need to do make my code dynamic I am fetching users from Approvers which is a Watchlist field on u_software table


against each software name we have 2 approvers in the watchlist how to get that field in my approver activity.




find_real_file.png