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 04:51 AM
Hi,
Try
answer.push(gr.manager.toString());
If my answer helped you in any way, please then mark it correct and helpful.
Kind regards,
Manas

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 04:53 AM
Try this.
When you push values to an array, you need to use .getValue('value') otherwise you are pushing a pointer to the GlideRecord and not a value.
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.getValue('manager'));
}
}
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2020 10:14 PM
Thanks for the reply!
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 05:48 AM
Hello,
Update the line to answer.push(gr.manager+'');
Thanks,
Jagadeesh