
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 07:59 AM
Hi Community,
Using Helsinki - helsinki-03-16-2016__patch7-11-02-2016
Following a recent audit I need to prevent any Requester being able to Approve their own Change Requests.
I have read a couple of articles similar to my situation but they have been specific to a particular Assignment Group and my scripting skills are non existent to be able to turn their suggestions into something that works!! I have also tried writing a Business Rules on the sysapproval_approver table but could not get this to work either.
I have attempted to change the below script from another post from 2014 to work in our Instance but I cannot get it to work - the best result was skipping the Peer check step of the workflow where an approval is required from the Assignment group of the Requester.
- answer = [];
- var approvers = new GlideRecord('sys_user_grmember');
- approvers.addQuery('group.name', 'IT Infrastructure Managers');
- approvers.query();
- while(approvers.next()) {
- if(approvers.user.toString() != current.requested_by.toString()) {
- answer.push(approvers.user.toString());
- }
- }
My version:
1. answer = [];
2. var approvers = new GlideRecord('sys_user_grmember');
3. approvers.addQuery('current.assignment_group');
4. approvers.query();
5. while(approvers.next()) {
6. if(approvers.user.toString() != current.requested_by.toString()) {
7. answer.push(approvers.user.toString());
8. }
9. }
I think the script is doing the following:
2 - Identifying the Group the Requester is in
3 - Is the Requester in the Assignment Group?
4 - ??
5 - ??
6 - If the Requester is in the Assignment Group
7 - ?? do something!
Many thanks in advance.
Steve Brown
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 08:28 AM
There is an additional quotes in the current.assignment_group which will not make it work. I have done a minor update to code
answer = [];
var approvers = new GlideRecord('sys_user_grmember');
approvers.addQuery('group', current.assignment_group); //Matches assignment group on change with the group membership table
approvers.query();
while(approvers.next()) {
if(approvers.user.toString() != current.requested_by.toString()) {
answer.push(approvers.user.toString());
}
}
I have tested this and it was working on my developer instance.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 08:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 08:54 AM
I think you should use the Approval - User activity instead of Approval - Group, Can you change it and check? We are adding users into the approval individually and not a group.
I believe there are more than 1 member in your group?
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2017 09:22 AM
Perfect!! Works just like you said it would after changing the Approval activity to Approval - User.
Thank you for getting me across the line!
Regards,
Steve.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 08:56 AM
Hi alikuttyka,
Sorry to bother you again. I have a slight amendment required for the script you provided where by I need the same functionality to prevent the Change Approvers of any Assignment Group from approving their own Changes as well.
I have attempted to use varying fields within the below lines of script by calling out different fields to no avail.
- var approvers = new GlideRecord('sys_user_group');
- approvers.addQuery('group', current.u_change_approvers);
This is an extract from toe workflow debug following my latest attempt! I'm just not sure what field to call out in the script so that the users identified as Change Approvers can not approve their own Changes:
Team Leader Review(3002cec037f9b640302ad3e853990ea1): No Approval User selected and advanced script encountered an error:Wrapped ConversionError: The undefined value has no properties. (answer = [];
var approvers = new GlideRecord('sys_user_group');
approvers.addQuery('group', current.u_change_approvers);
approvers.query();
while(approvers.next()) {
if(approvers.user.toString() != current.requested_by.toString()) {
answer.push(approvers.user.toString());
}
} ; line 6) (<refname>; line 163) (<refname>; line 173)
Any further assistance you can offer is appreciated.
Many thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 09:19 AM
Hi Steve,
Np, I need a bit more clarification. Now we have prevented the requester from approving the change. Is this a new field on the change?
It helps if you can add some screenshots of requirement.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response