Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

View rules for restricting admin

Not applicable

Hi Team,

Hope you all are fine,

 

I have a requirement to create a View rule for document management (ds_document) table so that the Newly created view for form and list can be seen only by a ABC group, even an admin should not see it.

View name - Security view

Group name - ABC (Only this group can see the records, even admin should not see it)

 

script in view rule:

(function overrideView(view, is_list) {

    // Add your code here
    answer = null;  // set the new view to answer
  
        if(gs.getUser().isMemberOf("DM Security group")){
            answer += "security_view";
        }
else {
answer = null;
}
       

})(view, is_list);
2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Community Alums 

Did you check if the view rule runs for admin? did you debug by adding logs?

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

Runjay Patel
Giga Sage

Hi @Community Alums ,

 

Use below code.

 

 if(gs.getUser().isMemberOf("DM Security group")){
            answer = "security_view";
        }
else {
answer = null;
}

Add role to manage view.

RunjayPatel_0-1730900398282.png

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------