Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set specific list views for specific Groups

Shawn Horley
Kilo Guru

Greetings folks.

So, I've created specific Groups for the people about to access our new Asset Management application. I've created one of the two Views that I'm going to need. Now I'm trying to figure out how to restrict those group members to seeing the view I've created for them.

CHeers

A.

1 ACCEPTED SOLUTION

Yes. Do this

 

 

(function overrideView(view, is_list) {

if(gs.getUser().isMemberOf('<Your group name 1>') || gs.getUser().isMemberOf('<Your group name 2>')) {
answer = "Admin";
} else if(gs.getUser().isMemberOf('<Your group name 3>'){
answer = "Technicians";
} else {
answer = "default";
}
// set the new view to answer

})(view, is_list);

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

11 REPLIES 11

SanjivMeher
Mega Patron
Mega Patron

You can write view rules.

Right click on the form header and select Configure->All and you should see view rules tab. Add the view rule to display views based on group

Following link should help

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/navigation_and_ui/task...


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv

Thanks for responding!

So, I had looked at this prior to asking the question, apologies on my part for not mentioning it. I'm not sure how to make that work based on specific groups as the filter conditions all seem to derive from the list column data itself.

I know that there is the Advanced option, but I have no idea how to script that rule.

You can add below script

 

(function overrideView(view, is_list) {

if(gs.getUser().isMemberOf('<Your group name>')) {
answer = "<View1>";
} else {
answer = "<View2>";
}
// set the new view to answer

})(view, is_list);

 


Please mark this response as correct or helpful if it assisted you with your question.

Why thank you Sanjiv!

I'll try that asap and let you know if I screwed it up or not 😉