Question about Views and View Rules

DeeMendoza
Tera Contributor

You know how in the header of a record/form, you can select which view to see the form in? How can I edit the choices of Views that a user can select based on their role?

 

I understand that View Rules simply set the view based on role, but my requirements are that if user belongs to Group A, they may select (from the header) View X, View Y, and View Z. Am I looking at the right place? It seems to me that View rules don't quite cover this.

I apologize for the seemingly basic question, but the documentation for view rules dont mention anything and because of the name of the topic it's hard to come up with meaningful search engine results

1 ACCEPTED SOLUTION

J Siva
Tera Sage

Hi @DeeMendoza 

View rules are used to enforce a specific view based on predefined conditions. By utilizing view rules, you cannot control the visibility of view lists in the form or list context menu.
While creating a view, we need to select roles for which it will be displayed, ensuring only users with the those roles can access it. In short, it is not possible to show or hide available views based on user groups.
Hope this helps.
Regards,
Siva

View solution in original post

5 REPLIES 5

Kieran Anson
Kilo Patron

On the UI View [sys_ui_view] record itself you can specify roles. But those aren't table specific. So adding a role to the "Default View" would require that role across tables. So you may need to create unique view names for your subset of tables.

 

If you want to limit users, you'd need to remove 'view_changer' which is what provides the ability to switch between the views in the list. Without that role, you don't get an option of what view you're served with

J Siva
Tera Sage

Hi @DeeMendoza 

View rules are used to enforce a specific view based on predefined conditions. By utilizing view rules, you cannot control the visibility of view lists in the form or list context menu.
While creating a view, we need to select roles for which it will be displayed, ensuring only users with the those roles can access it. In short, it is not possible to show or hide available views based on user groups.
Hope this helps.
Regards,
Siva

Ankur Bawiskar
Tera Patron
Tera Patron

@DeeMendoza 

you will have to write that script in each of the view rule for your individual views

Example: when you create a view rule for View X use this script

(function overrideView(view, is_list) {

    if (gs.getUser().isMemberOf('Group A'))
        answer = 'view_x';
		
})(view, is_list);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@DeeMendoza 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader