- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2020 02:12 AM
i want to fetch few groups in an array,
after that if the change request is having approval for this groups the Approval automatically has to set No longer Required.
so here how can i write an business rule, which will check the approval group, if the approval group is one of these fetched ones, then the approval has to set "No longer Required"
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2020 01:48 AM
Hi,
so can you add a log above if and print current.assignment_group and groups array and check what the value it contains.
Technically,both should be group sys_ids and if you think the assignment group present in your list of groups, then manually verify the sys_id of assignment group in the groups array or in your table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2020 04:06 AM
i mean check the value inside that table for that CR sys_id.
Call me. May be it is faster to fix it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2020 07:53 AM
i have check this script in back ground script, yeah it is working fine cancelling the approvals
can you please change this script for using the same in BR, as i tried and facing some issues.
var grGroupApproval = new GlideRecord('sysapproval_group');
grGroupApproval.get('df75eba41b924054a01f2f876e4bcb6a');
var grChange = new GlideRecord('change_request');
grChange.get(grGroupApproval.parent);
gs.log('parent '+ grGroupApproval.parent + ' risk ' + grChange.risk);
if(grChange.risk==4)
{
gs.print('calling 1');
var groups = [];
var gr_groups = new GlideRecord("u_epic_group_approvals");
gr_groups.query();
while(gr_groups.next()) {
groups.push(gr_groups.getValue("u_epic_group_approvals"));
var arrayUtil = new ArrayUtil();
gs.log("Entered into the BR " +grGroupApproval.assignment_group.getDisplayValue());
if(arrayUtil.contains(groups, grGroupApproval.assignment_group)) {
gs.log("Entered into the If condtion"+grGroupApproval.approval+"-------"+grGroupApproval.sys_id);
gs.eventQueue("TEstBR",grGroupApproval,grGroupApproval.sys_id,grGroupApproval.approval);
}
gs.print('calling 2');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2020 09:18 PM
Here you go. But this will work only if the risk is updated before the approval is changed to requested.
If the value of risk in CR is updated after the approval entry changes to requested, then your Br executes first and it will not have the value of risk by that time.
var grGroupApproval = new GlideRecord('sysapproval_group');
grGroupApproval.get(current.sys_id);
var grChange = new GlideRecord('change_request');
grChange.get(grGroupApproval.parent);
gs.log('parent '+ grGroupApproval.parent + ' risk ' + grChange.risk);
if(grChange.risk==4)
{
gs.print('calling 1');
var groups = [];
var gr_groups = new GlideRecord("u_epic_group_approvals");
gr_groups.query();
while(gr_groups.next()) {
groups.push(gr_groups.getValue("u_epic_group_approvals"));
}
var arrayUtil = new ArrayUtil();
gs.log("Entered into the BR " +grGroupApproval.assignment_group.getDisplayValue());
if(arrayUtil.contains(groups, grGroupApproval.getValue("assignment_group"))) {
gs.log("Entered into the If condtion"+grGroupApproval.approval+"-------"+grGroupApproval.sys_id);
gs.eventQueue("TEstBR",grGroupApproval,grGroupApproval.sys_id,grGroupApproval.approval);
}
gs.print('calling 2');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 09:13 AM
hi Asif,
i have one more requirement, when the assignment group of the change request is related to EPic groups (we have list of epic related groups stored in one table), then if change management group approvals are added to sysapproval_group, automatically the approvals has to set as "No longer Required"
you can modify this BR accordingly.
var groups = [];
var gr_groups = new GlideRecord("u_epic_group_approvals");
gr_groups.query();
while(gr_groups.next()) {
groups.push(gr_groups.getValue("u_epic_group_approvals"));
}
var grChange = new GlideRecord('change_request');
grChange.get(current.parent.toString());
gs.info(' change number '+ grChange.number + ' risk ' + grChange.risk);
var riskval = grChange.risk.toString();
if(riskval=='4')
{
var arrayUtil = new ArrayUtil();
//check if the assignment group falls in our groups.
gs.log("Entered into the BR " +current.assignment_group.getDisplayValue());
if(arrayUtil.contains(groups, current.assignment_group)) {
//If yes, then update approval to no longer required.
gs.log("Entered into the If condtion"+current.approval+"-------"+current.sys_id);
gs.eventQueue("EpicApprovalsAutoCancel",current,current.sys_id,current.approval);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 09:25 AM
Hi,
Could you create a new post and let me know.
Mark the comment as a correct answer and helpful if it helps.