Adding multiple approvers in workflow approval user activity?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 04:43 AM
I have written the below script to add various group managers as approver, created a variable as list collector named it as 'group_names' now all the group managers of the selected groups should be added as approver in the activity, but the issue happening is only first selected group manager is getting added as approver ?
answer = [];
// answer.push('id1');
// answer.push('id2');
var grp = current.variables.group_names.getDisplayValue();
var arraylist = grp.split(",");
for(var i=0;i<arraylist.length;i++)
{
gr = new GlideRecord ('sys_user_group');
gr.addQuery('name',arraylist[i]);
gr.query();
if(gr.next())
{
gs.log('mk'+i+''+arraylist[i]);
answer.push(gr.manager);
}
}
Any help will be appreciated.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 10:14 PM
Tried the same still no luck it is still adding the approval manager only for the first selected group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 06:51 AM
{
gs.log('mk'+i+''+arraylist[i]);
answer.push(gr.getValue('manager'));
}
return answer;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 10:14 PM
Tried the same still no luck it is still adding the approval manager only for the first selected group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 01:49 AM
Hi,
Please Follow below line of code:-
answer=[];
var grp = current.variables.group_names.toString();
//var arraylist=[] ;
var arraylist = grp.split(",");
var len=arraylist.length;
for(var i=0;i<len;i++)
{
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id',arraylist);
gr.query();
while(gr.next())
{
answer.push(gr.manager);
}
}
If i was able to solve your query, Please mark my answer correct and helpful.
Thanks & Regards
Prasant kumar sahu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 01:57 AM
HI,
please follow the link you can find some information regarding to this:
Thanks,