Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Restrict view by role

Log in to subscribe to topics and get notified when content changes.

Restrict view by role

You can use a script to control the form view used by different roles.

Caution: The customization described here was developed for use in specific instances, and is not supported by ServiceNow Technical Support. This method is provided as-is and should be tested thoroughly before implementation. Post all questions and comments regarding this customization to our community forum.

Name: Restrict View by Role

Type: System UI > View Rules

Table: Any

Description: Generally the view used on a form is controlled by either specifying the sysparm_view parameter in the url or module properties, or by inheriting the view from the previous form or list. Sometimes this does not apply, such as when opening a referenced field form from a record producer. In this case, you may want to control the view of the form based on roles. This script assumes there is a view called ess available to the current table.

  • view - A string containing the name of the current view.
  • is_list - A Boolean value indicating whether this is a list view.


(function overrideView(view, is_list) {
//Force non-itil users to use the ess view
if (gs.hasRole("itil"))
if (view.startsWith("ess"))
// do not change view if it starts with sys_ (e.g. sys_ref_list)
if (view.startsWith("sys_"))
answer = "ess"; // set the new view to answer
})(view, is_list);