Scripting in View Rule

codedude
Mega Expert

I have written a very simple script in the View Rule, but it is not working for some reason. I am wanting to show the ess view for any user who is not an admin....

Here is my script:

(function overrideView(view, is_list) {

  answer = null;   // set the new view to answer

  var isAdmin = g_user.hasRole('admin');

  if (!isAdmin) { answer = "ess"; }

})(view, is_list);

Any advice?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Josh,



g_user is a client side operation. The view rule is running on the server.



Try



var isAdmin = gs.hasRole('admin');


View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

Hi Josh,



g_user is a client side operation. The view rule is running on the server.



Try



var isAdmin = gs.hasRole('admin');


Thank you very much