Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

View Rule forces one role to a specific view and also the Admin role.

claires
Tera Expert

We have a very basic View Rule set up.  It is suppose to force our Support Center staff to a specific view of the Incident form and also the User Profile.  

claires_0-1714571368274.png

It is also forcing the Admin role the same way.  I have been told this is as designed.  It makes troubleshooting issues for non-support center staff very difficult.  The rule is from 2016.  I have read the docs and I don't see anywhere where it includes the Admin role in the rule.  Has anyone else experienced this and is there a work around.  It stops the Admin role from seeing the View Selector completely. 

 

On an Incident form, I see this:

 

claires_1-1714571432673.png

 

I see no View Selector on the Incident form

claires_3-1714571586639.png

 

 

On a Work Order, I see the View Selector:

claires_2-1714571497935.png

 

 

Any ideas, suggestions?  

We are on Vancouver

 

#ITSM #ViewRule

2 REPLIES 2

Ben Rowny
Tera Guru

The g_user.hasRole() method is slightly tricky, because it returns true if the logged in use has the specified role OR the admin role.  In this case, you'd want to use g_user.hasRoleExactly().  Here is a pretty good article on it: https://www.servicenow.com/community/itsm-articles/uses-of-hasrole-methods-client-and-server-side/ta...

Travis Rogers
ServiceNow Employee
ServiceNow Employee

This video has a good example of handling multiple view/role groupings within one scripted view rule. https://www.youtube.com/watch?v=PcqiNtHFOFk&t=1s

This video explains view rules in ServiceNow along with a demonstration. View rule is a configuration that allows ServiceNow to load different views of a form for different users according to the specified conditions. To configure a view rule, navigate to All - System UI - Viewrules Click on new ...