Visibilty of tickets based on Parent-child assignment group

KARAN24
Tera Contributor

Hi Team,

 

We have 2 groups Group A and Group B,

Group B (Child)is child of Group A(Parent)

Requirement is - Any member of Group A should be able to see all the incidents assigned to their group as well as its child group.

And, Any member of Group B should be able to see only the incidents which they are part of,they should not see any tickets of there parent group.

 

Any help will be highly appreciated.

 

Thanks,

Karana

 

 

2 REPLIES 2

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @KARAN24 ,

 

You can achieve this by simple Query business rule on incident table as below, by using this you will be able to restrict user from seeing records were assignment group is set to parent group.

 

(function executeRule(current, previous /*null when async*/) {

var gr1 = new GlideRecord('sys_user_grmember');    //records to show child group members change the sys_id of your child group in below line.
    gr1.addEncodedQuery('group=572ed3251be8f1109eb3bb751a4bcb0c^user='+gs.getUserID());
    gr1.query();
if(gr1.next()){
    gs.info('kaustubh is member of child group');
    current.addEncodedQuery('assignment_group!=287ebd7da9fe198100f92cc8d1d2154e');    // sys_id of parent group.
        current.query();        
    }
 
})(current, previous);
 
 
 

Kindly mark my answer as Correct and helpful based on the Impact.

Regards,

Siddhesh

Hi Siddhesh,

 

Mine requirement is ,any group who has parent group,should not be able to see the tickets of the parent group,But parent group should be able to see the tickets of all child groups.

Currently ,I have created Query BR,which displays all the tickets of its parent as well as child.Here is the code.

//var groups = j2js(gs.getUser().getMyGroups().toArray());
var my_groups = gs.getUser().getMyGroups();

var groupsArray = my_groups.toString().split(',');

var arr = [];

var gr = new GlideRecord('sys_user_group');
//gr.addQuery('parent', 'IN', groupsArray).addOrCondition('parent.parent', 'IN' ,groupsArray);
gr.addQuery('parent''IN', groupsArray);
gr.query();
while(gr.next()){
arr.push(gr.getValue('sys_id'));
}

var arrayUtil = new global.ArrayUtil();

var finalArray = arrayUtil.concat(groupsArray,arr);

finalArray = arrayUtil.unique(finalArray);

var qc = 'assignment_group.sys_idIN' + finalArray;
gs.info('FINALNEW: ' + qc);


current.addEncodedQuery(qc);
 
Thanks,
Karan