- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:09 AM
Hello All,
Requirement :
We want to prevent users with the "View_changer" role from changing the view on the Requestor table—both at the form level and list level—without affecting other tables. However, Admin users should be exempt from this restriction.
I have implemented a View Rule for the view_changer role. When I impersonate a user with the view_changer role, they are able to see the requestor_details_view by default. However, they are also able to switch to other views, but they cannot access the default view. Could you please suggest what the issue might be?
View rule code
(function overrideView(view, is_list) {
// Add your code here
if(gs.hasRole('view_changer') && !gs.hasRole('admin')){
answer = 'requestor_details_view' ; // set the new view to answer
}
else{
answer = view;
}
})(view, is_list);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:39 AM
I believe then it's not possible to achieve your case.
With that KB it says they can change/switch the view but the view rule will run again and set the view
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:40 AM
Thanks for your reply.
Our client's requirement is to prevent users with the 'View_changer' role from changing the view on the Requestor table only, while still allowing them to switch views on other tables.