Control record visibility in list view

Vdevmat33
Tera Contributor

Hi,

I have been exploring record visibility in Lists, so while working on it came across a scenario where i was trying to show records in retired state for some specific users (who are member of testing group).

- If user is not member of testing group, records with retired state should not be visible to them but records with other state should be visible.

- One of the approach i followed is - Created a table level Read ACL and added ACL script to check state and group membership. Based on these conditions returning answer.

- This approach works, but the issue is, If user is not member of testing group and there are records other than retired state and retired state in list, receiving error which says - security constraint prevents access. So there are records available in list but the mentioned error message also appears. This can mislead one, so trying to hide the unwanted records without any error message.

Can someone please suggest how this can be achieved? It will be helpful. Thanks

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Vdevmat33 

 

You can write before query business rule :

 

 if ( !gs.getUser().isMemberOf("Testing group")) {
       current.addEncodedQuery("state!=retired");  //you can use backend value for retired
    }

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

2 REPLIES 2

Vishal Birajdar
Giga Sage

Hi @Vdevmat33 

 

You can write before query business rule :

 

 if ( !gs.getUser().isMemberOf("Testing group")) {
       current.addEncodedQuery("state!=retired");  //you can use backend value for retired
    }

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Badal Khojare
Mega Sage
Mega Sage

Hi,

If you do not want the message you will have to go with Before query BR. Try using Vishal's script it might solve your issue.

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023