The CreatorCon Call for Content is officially open! Get started here.

View rule is not working

sunil10
Tera Contributor

Hello everyone, I have created a view called "Test view" which have only 4 fields and should be applicable to only list view, and this view should be visible to only users of group "Database". I created this view rule but it is not working? It is visible to all the users irrespective of groups

(function overrideView(view, is_list) {

   if (is_list && gs.getUser().isMemberOf('Database')) {
    answer = 'test_view';
}

})(view, is_list);

  

6 REPLIES 6

@sunil10 

So database users are navigated to correct list view but they are able to see the other views?

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

Bshirisha
Tera Contributor

Hi @sunil10,

As far as i know a View Rule by itself will not hide a view.

It only decides which view is automatically selected.

Other users can still see and manually select that view in the dropdown if they have access to the list layout.   If you need to hide the view from everyone except your target group, along with view rule ,set the field "Hidden" to true in view that you have created.