Restrict HR task visibility

kartikey
Tera Contributor

Hi Everyone,

How can i restrict HR task visibility from other HR task members on the same parent HR case.
When there are two HR tasks created on the same Parent HR case, i don't want members of assignment group A of one task to view the details of another another task assigned to another assignment group B.
There are no common members of the two assignment group A and B.

Regards,
Kartikey

3 REPLIES 3

Community Alums
Not applicable

In ServiceNow, you can control access to records using Access Control List (ACL) rules. You can create a new ACL rule for the HR Task table (sn_hr_core_task) to implement your requirement.

Here's a rough outline of how you could set up the ACL:

Navigate to System Security > Access Control (ACL).
Click New.
Fill in the form with the following details:
Operation: Read (and also Write if you want to restrict edit access)
Name: This should be the name of the table, sn_hr_core_task
Type: Record
In the Script field, add a script that checks if the current user is a member of the assignment group of the current record. Here's an example script:


javascript

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

// Check if the current user's sys_id is in the assignment group of the current record
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.addQuery('group', current.assignment_group);
groupMembers.query();

while (groupMembers.next()) {
if (groupMembers.user == gs.getUserID()) {
return true;
}
}

return false;

})(current, previous);

 


Set the Admin Overrides to No, which ensures that even admins will be subject to this rule.
Click Submit to save the ACL.

Hi,

i tried the same,  but instead of script i used conditions with 'assignment group' is dynamic 'one of my groups'.
but its not working due to OOTB ACL's i believe.

Sandeep Rajput
Tera Patron
Tera Patron

@kartikey You can make changes in the read ACL of the sn_hr_core_task table as follows.

 

Screenshot 2024-03-04 at 3.16.17 PM.png

on the existing ACL add the condition Assignment group is dynamic One of my assignment groups.