View rules for restricting admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 04:00 AM
Hi Team,
Hope you all are fine,
I have a requirement to create a View rule for document management (ds_document) table so that the Newly created view for form and list can be seen only by a ABC group, even an admin should not see it.
View name - Security view
Group name - ABC (Only this group can see the records, even admin should not see it)
script in view rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 05:35 AM
Did you check if the view rule runs for admin? did you debug by adding logs?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 05:40 AM
Hi @kumaraj ,
Use below code.
if(gs.getUser().isMemberOf("DM Security group")){
answer = "security_view";
}
else {
answer = null;
}
Add role to manage view.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------