Mark HR case confidential and once its mark true then case should be visible to HR admin

aastha3
Giga Contributor

Created a check box for HR case confidential . When its checked- true then the HR case should be only visible to HR admin.

I dont want to go with ACL . Any other way to approach this?

Thanks

 

14 REPLIES 14

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use query business rule for this; if you don't want ACL approach

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

We have to write if condition right  ? What code needs  to be written to achieve this?

 

Hi,

So basically you want this:

1) So if the checkbox is true for any record then that record to be shown to below user

a) if logged in user is the opened_by person

2) if the checkbox is false then no restriction for the record

Does user with hr admin have no restriction; they can view all? if yes then I have added the BR not to trigger for admin and hr admin

BR: query business rule on sn_hr_core_case table

Condition: gs.getSession().isInteractive() && !gs.hasRole('admin') && !gs.hasRole('sn_hr_core.admin')

Script:

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


if(current.<checkBox>){

current.addQuery('opened_by', gs.getUserID());

}


})(current, previous);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Yes whenever any user checks on the mark confidential true/false field then opened for person in that HR case and anyone who has hr_admin role should be able to view the HR  case no one else.

If the mark confidential is unchecked it should  be visible to everyone.

 

insert and update BR should also be used with query BR  right ?