How to restrict a form view based on the user group.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2024 05:50 AM
Hi,
I created a new view in the user table, now all the ITIL users can able to see the new view. But I want to give access to this view for few particular groups only, and other itil users who are not in the mentioned groups can't able to see/ open this new view.
I tried to create a view rule, but failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2024 10:58 PM
please share your view rule; it should be an easy one
if(gs.getUser().isMemberOf('Group ABC'))
answer = 'yourViewName';
else
answer = ''; // default 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
‎10-19-2024 03:45 AM
HI When I used the above script, below are the outcomes.
-All users can able to open the user form with the new view.
-But still all ITIL users have access to this new view.
-Before implementing new view rule all ITIL users can't able to open the 'Default view' (only admins have this view access.)
- Now all ITIL users can able to access the default view. This is not a good outcome.
Below script I used'
if (gs.getUser().isMemberOf("ABC group")) {
answer = "new_view";
} else {
answer = '';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2024 03:50 AM
HI @Ankur Bawiskar ,
After implementing the above script in the view rule below are the outcomes.
- Still all ITIL users, who are not in that group can able to access the new view.
- And before implementing this view rule, ITIL users can't able to open the default view in the user form.
-Now all the ITIL users can able to open the default view in the user form, which is like a security breach.
if (gs.getUser().isMemberOf("ABC group")) {
answer = "new_view";
} else {
answer = '';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2024 09:46 PM
did you check the view rule is getting executed and view name is correct?
Did you add log statements and check?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader