- 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-07-2020 05:30 AM
my team did not felt good approach going with array, so have created a table and had created one reference field which will point to the list of groups.
so can u suggest me with code, how can i approach this way

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2020 05:49 AM
okay. I can understand that if there are lot of groups best to store in a table. So i have modified the code to read the data from the table. In below code, change the tablename and column to your data and check.
//Query your table and get teh groups into this array. This way, you don't need to hardcode anything.
var groups = [];
var gr_groups = new GlideRecord("your_table");
gr_groups.query();
while(gr_groups.next()) {
groups.push(gr_groups.getValue("your_column"));
}
var gr = new GlideRecord("sysapproval_group");
//put your Change request sys_id below.
gr.addQuery("parent","41cdb152db252200a6a2b31be0b8f527");
gr.addQuery("approval","requested");
gr.query();
var arrayUtil = new ArrayUtil();
while(gr.next()) {
//check if the assignment group falls in our groups.
if(arrayUtil.contains(groups, gr.getValue("assignment_group"))) {
//If yes, then update approval to no longer required.
gr.approval="not_required";
gr.update();
}
}
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2020 07:12 AM
hi Asif,
do i need to change the parent sys_id here in the code?
what about array we are using in this code? do we need this still as we have created a table and stored
and when it has to work, before update / insert update?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2020 07:42 AM
Yes, the array is needed for comparison.
if you are going to create a BR on sysapproval_group table, then create it after insert and put the code like this. Add a condition for approval is requested so that it runs only for the approvals which are requested.
If you want to run only for change requests then add another condition AND
say parent startswith CHG
//Query your table and get teh groups into this array. This way, you don't need to hardcode anything.
var groups = [];
var gr_groups = new GlideRecord("your_table");
gr_groups.query();
while(gr_groups.next()) {
groups.push(gr_groups.getValue("your_column"));
}
var arrayUtil = new ArrayUtil();
//check if the assignment group falls in our groups.
gs.log("Entered into the BR");
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="not_required";
}
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2020 09:21 PM
have tried and no logs has entered in system logs after executing this. seems some problem with this Asif.
Mark the comment as a correct answer and helpful if it helps.