- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 05:44 PM
Hello All.
If "Request by" user is the member of the Approvers group (Assignment Group) we should exclude this user from the Approvers list. To exclude "Requested by" user from the Approvers list I'm using the code bellow. Debugging statement [workflow.info('APPROVER = ' + approvers.user.toString());] recording in the log all approvers correctly. In simple words the code is working. However, retrieved approvers are not displayed on the Approvers list on the form.
Please, any suggestions for me? Thank you in advance for your help.
SCRIPT:
answer = [];
var approvers = new GlideRecord('sys_user_grmember');
approvers.addQuery('group', current.assignment_group);
approvers.query();
while(approvers.next()) {
if(approvers.user.toString() != current.requested_by.toString()) {
workflow.info('APPROVER = ' + approvers.user.toString());
answer.push(approvers.user.toString());
}
}
Approvers are not displayed on the list:
Even the log says approvers are retrieved correctly:
Solved! Go to Solution.
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 07:38 PM
Hi,
I'm assuming that you are using "Approval group" activity and not "Approval User" activity in the workflow. If yes, then switch it to the "Approval user" activity and the script should work fine.
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 07:27 PM
Try defining your answer at the end of your script, i.e.
var appAr = [];
var approvers = new GlideRecord('sys_user_grmember');
approvers.addQuery('group', current.assignment_group);
approvers.query();
while(approvers.next()) {
if(approvers.user.toString() != current.requested_by.toString()) {
workflow.info('APPROVER = ' + approvers.user.toString());
answer.push(approvers.user.toString());
}
}
answer = appAr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2018 11:51 AM
I tried as you suggested, Erik. It raised an error, - illegal access to getter method getMessage. Thank your willing to help and for your kindness.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2018 07:38 PM
Hi,
I'm assuming that you are using "Approval group" activity and not "Approval User" activity in the workflow. If yes, then switch it to the "Approval user" activity and the script should work fine.
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2018 12:03 PM
Super! You are absolutely right, Pradeep. We used "approval group" activity, when I replaced it with the "approval user" activity the code is working like a charm. 🙂 I'm not sure why, specially regarding to the description of the "approval group" it should create an approval record for each member of the group. But the problem is solved. Thanks a million!