Restrict the HR case visibility using a Before-Query business rule

mnreddy
Mega Guru

Hello All,

I created a Before-Query business rule to restrict the HR case visibility based on the group membership. If you are a member of group "xyz" then you should see only the HR cases assigned to group "xyz". This is working as expected. However, when a member creates a new HR case with their group as the assignment group and saves the record, they are getting a message "Info Message You do not have permission to read the created record" even though the created record is for their group. When they search the record they can read the data as they have access to read as per the business rule. I am not sure why I am getting that information message as soon as I save the case? Any help is much appreciated. Thank you.

 

Regards,

Mnreddy.

1 ACCEPTED SOLUTION

Hi,

on which table you are checking this

OOB there is 1 query BR on HR Case table

Regards
Ankur

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

View solution in original post

14 REPLIES 14

@mnreddy 

the issue is toArray() won't work in scoped application i.e. HR Core scope

so use this

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

var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());

current.addQuery("assignment_group", "IN", groups);

})(current, previous);

Regards
Ankur

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

Thanks for your response @Ankur Bawiskar. But unfortunately it's not working either. With the latest updated logic, Users are able to see all HR cases even the cases they are not a part of (Assignment group they are not a part of).

 

Regards,

Mnreddy.

Hi,

on which table you are checking this

OOB there is 1 query BR on HR Case table

Regards
Ankur

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

Thank you @Ankur Bawiskar . I know I was missing something and that is it. We actually have a custom query business rule in place and that was causing the issue. It is now working fine :-).

 

Regards,

Mnreddy.

You are welcome.

Happy weekend.

Regards
Ankur

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