- 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:16 AM
I remember participating in your similar thread earlier and you had shared a KB article, I can't access that
so you are saying view rule is working fine but they are able to switch views?
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:28 AM
Yes, that's correct.
I'm sharing the article again. Could you try opening it in a different browser? I'm able to access it on my end.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0719228
- 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:25 AM
Hi @Khalid9030
You can remove view_changer role from users as simple.
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************