The CreatorCon Call for Content is officially open! Get started here.

how can i fetch groups in to an array

lakng
Tera Contributor

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"

 

1 ACCEPTED SOLUTION

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 the comment as a correct answer and helpful if it helps.

View solution in original post

48 REPLIES 48

it means your business rule is not accessing the "parent" field value.

this business rule is on "insert" , again i am just assuming here , might be possible once the business rule get executed, you dont have value in parent column and that might be a reason its giving you null. 

Hi,

I think you need to change the condition

if(changeRec.getValue('risk') == 4){

lakng
Tera Contributor

no risk value as null

Hi,

As Harsha suggested already, add the logs once.

Also, i have updated the code slightly. Check this.

 

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 changeRec= new GlideRecord("change_request");
changeRec.get(current.parent);

gs.log('Risk Value '+ changeRec.getValue('risk') );

if(changeRec.getValue('risk') == 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("TEstBR",current,current.sys_id,current.approval);
  }
}

Mark the comment as helpful if it helps.

lakng
Tera Contributor

Hi Asif, still risk value is showing as null in logs