Restrict HR incidents to only members of the HR group

Community Alums
Not applicable

I have a requirement to restrict any incidents that are assigned to the HR group to only be able to be seen by the members of that group. The users that are in the HR group have the ITIL role, as well as users of other groups. 

How should my business rule be configured to have only HR team members see the incidents that are assigned the HR group. See my Business Rule script below... How should the "When to Run" and "Actions" tab be configured? or does anything on those tabs need to be changed at all with the correct advanced script?

 

Condition: !gs.getUser().isMemberOf('<ServiceNow - HR>') || current.opened_by == gs.getUserID()

Script:

(function executeRule(current, previous /*null when async*/ ) {
 
        if (gs.isInteractive()) {
           
            testSec();
           
        }
 
        function testSec() {
            var testGroups = gs.getProperty('<ServiceNow - HR>');
            var myGroupsArr = getMyGroups().toArray();
            var restrictRecord = true;
               for (var i = 0; i < myGroupsArr.length; i++) {
                if (testGroups.indexOf(myGroupsArr[i]) >= 0) {
                    restrictRecord = false;
                }
            }
if (restrictRecord == true) {
                    var qc = current.addEncodedQuery("<assignment_group=405fdc544788aa5092e4054c416d4329>");        
                }
            }
        })(current, previous);
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

is this for incident table?

If yes then remember there is already OOB 1 query business rule on incident table

So you will have to ensure that is updated with the above use-case and the existing logic of the business rule

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Yes, this is on the incident table. There are several active business rules on the incident table. How can I determine which one is the OOB1?

@Community Alums 

there is only 1 query business rule on incident table

Ensure you also update the OOB table.None READ ACL with the same conditions

AnkurBawiskar_0-1740666576751.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Thank you for your assistance. 

Are you saying that both my HR Incidents query business rule and the OOB incident query business rule should be the same? Should they both be active or just one? 

Please provide specifics.