- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 12:39 AM
Can anyone please help in how to write the code in the below BR for the below scenario?
var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sysapproval', current.sysapproval);
grAppr.addQuery('u_injectorss',false);
grAppr.query();
while (grAppr.next()) {
// help me with the code
}
There are total 3 approvals. If one approval state is approved the other 2 approval states should be set to 'No Longer Required'.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:47 AM
Hello,
You have to create an after business rule :
Script :
(function executeRule(current, previous /*null when async*/ ) {
var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sysapproval', current.sysapproval);
grAppr.addQuery('u_injectorss', false);
grAppr.addQuery('approver', '!=', current.approver);
grAppr.query();
while (grAppr.next()) {
grAppr.state = "not_required";
grAppr.update();
}
})(current, previous);
Result :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 01:00 AM
Hi,
First you should change this in your workflow, see Group Approval activity in workflow and make sure these options are selected, generally when someone approves then others state moves to 'No longer required' automatically. Mark my answer as correct if that helps.
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:17 AM
Can you pls help in script without updating in the workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:47 AM
Hello,
You have to create an after business rule :
Script :
(function executeRule(current, previous /*null when async*/ ) {
var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sysapproval', current.sysapproval);
grAppr.addQuery('u_injectorss', false);
grAppr.addQuery('approver', '!=', current.approver);
grAppr.query();
while (grAppr.next()) {
grAppr.state = "not_required";
grAppr.update();
}
})(current, previous);
Result :