Admin need to override the view rules

Shashank30
Tera Contributor

Hi,

i need to write a view rule, the view name is test.

the admin role users should not have the view rule

they can able to change the view.

Can any one suggest what should be written in scripting ,

i have given the view name.

find_real_file.png

 

find_real_file.png

Admins need to have the option to change the view

7 REPLIES 7

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Take sample script

Pass your view name in place of 'ot'

(function overrideView(view, is_list) {
    if (gs.hasRole("admin"))
        return;

    if (gs.hasRole("cmdb_ot_viewer"))
        answer = "ot";
})(view, is_list);

For your requirement, below should be script

(function overrideView(view, is_list) {

    if (!gs.hasRole("admin"))
        answer = "test";
})(view, is_list);

Mark my answer as correct if that helps

Please hit like and mark my response as correct if that helps
Regards,
Musab

find_real_file.png

i added it but its not working

admins cant able to change the view

the view what i need to add is default view, default view is having empty value in it, so i passed "" in the script

Confused about your requirement, can you briefly explain ?

Please hit like and mark my response as correct if that helps
Regards,
Musab

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Lets keep admin role aside for a while

You are saying non-admins should see the view Test and admins should see the default view right

(function overrideView(view, is_list) {

	if (!gs.hasRole("admin"))
		answer = "test";

})(view, is_list);

regards
Ankur

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