Restrict access to choose a group

DIVI1
Tera Expert

Hi, 
I need some help with a part of code.

I want to restrict access to assign tickets to one of a group, it should available only if user is Member of specific group.

 

So I have something like that: 

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

    if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) { 
        current.addQuery('sys_id', '3d72a95e1b7c355062cfca62604bcb90'); 
	}

})(current, previous);


But unfortunately it doesn't work properly cause here if user is member of group "ABC" can see only group "XYZ",

 nad That's what I want to make, group "XYZ" should be able to choose/visible only by users which are member of group "ABC" 

 

 

4 REPLIES 4

Aman Kumar S
Kilo Patron

Hi @DIVI1 

Change your script to 

 if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) { //sys_id of ABC
        current.addQuery('assignmnet_group', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group
	}
Best Regards
Aman Kumar

Hi, 
Thanks Now users of group ABC can see all groups and that's fine, but users which are not member of group ABC still can choose group "XYZ" from assignment_group field. How to restrict that ? "else" something I think?

Try this:

if (gs.getUser().isMemberOf('bd72a95e1b7c355062cfca62604bcb9c')) { //sys_id of ABC
        current.addQuery('assignmnet_group', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group
	}
else{
  current.addQuery('assignmnet_group', '!=', '3d72a95e1b7c355062cfca62604bcb90'); //Sys_id of XYZ group

}
Best Regards
Aman Kumar

Still the same, maybe remove option or something ?