Restrict access to tickets based on assigned group or ownership

MichaelW
Tera Contributor

Hi,

I have a business rule I implemented as we have a group of users outside of out Core IT area that we want to be able to assign certain incident, requests etc to work on.  We didn't want them to have full access to all other items though as no need for them to see it.  I made the below rule that works fine from that point of view however it stops them from seeing any tickets that are in their name or watchlist as those tickets are not part of the correct assignment group to meet my rule.  So I need to modify it so if assigned to one of their groups or they are the caller, requester or watch list they can see the tickets.  I could maybe do with ACL but I'm trying to keep it simple and not have to change a heap of ACL's to get this to work in both cases.

 

 

 

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

if (gs.hasRole('itil') && !gs.hasRole('admin') && gs.getUser().isMemberOf('LMS Support')) {
current.addEncodedQuery("assignment_group=javascript:gs.getUser().getMyGroups()");
}

})(current, previous);

 

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @MichaelW ,

You can update your encoded query something as below:

caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^ORwatch_listLIKEjavascript:gs.getUserID()
Best Regards
Aman Kumar

View solution in original post

4 REPLIES 4

Aman Kumar S
Kilo Patron

Hi @MichaelW ,

You can update your encoded query something as below:

caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^ORwatch_listLIKEjavascript:gs.getUserID()
Best Regards
Aman Kumar

Hi Aman,

Thanks you very much.  Still testing but this seems to be working the way I wanted thanks.  Modified a little to use a different caller field I have on all tables.  Code below for reference if anyone else is looking.

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

if (gs.hasRole('LMS Support')){
current.addEncodedQuery("u_who_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^ORwatch_listLIKEjavascript:gs.getUserID()");
}

})(current, previous);

 

Actually it's affecting all users not just those that have that role 😞

I'm sure i'll get it there though.

SmitP
Tera Contributor

Were you able to get it resolved? I am also looking for something similiar