Admin need to override the view rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:45 AM
Hi,
i need to write a view rule, the view name is test.
the admin role users should not have the view rule
they can able to change the view.
Can any one suggest what should be written in scripting ,
i have given the view name.
Admins need to have the option to change the view
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 12:50 AM
Hello,
Take sample script
Pass your view name in place of 'ot'
(function overrideView(view, is_list) {
if (gs.hasRole("admin"))
return;
if (gs.hasRole("cmdb_ot_viewer"))
answer = "ot";
})(view, is_list);
For your requirement, below should be script
(function overrideView(view, is_list) {
if (!gs.hasRole("admin"))
answer = "test";
})(view, is_list);
Mark my answer as correct if that helps
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 01:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 03:20 AM
Confused about your requirement, can you briefly explain ?
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 01:19 AM
Hi,
Lets keep admin role aside for a while
You are saying non-admins should see the view Test and admins should see the default view right
(function overrideView(view, is_list) {
if (!gs.hasRole("admin"))
answer = "test";
})(view, is_list);
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader