Restrict views based on role.

Divya57
Tera Expert

I had a requirement, based on roles the for views should be restricted. My requirement is if a user as 'itil' role, then he only 'additional info' view should be visible. Check below image.

find_real_file.png

I tried creating view rules with below code. But its not working. Please your inputs are appreciated.

(function overrideView(view, is_list) {

// Add your code here
if(gs.hasRole('itil')){
answer='additional_info';
}
else
answer = null; // set the new view to answer

})(view, is_list);

11 REPLIES 11

Apeksha Joshi
Kilo Guru

Hi Divya,

please follow these links it might help you :

https://community.servicenow.com/community?id=community_question&sys_id=49314be5db98dbc01dcaf3231f961944

https://community.servicenow.com/community?id=community_question&sys_id=5f10d3e5dbdcdbc01dcaf3231f9619d7

 

Hope this helps !

Regards 

Apeksha 

I tried but its not working

Anurag Tripathi
Mega Patron
Mega Patron

You have to be sure that for all users one view rule is applicable, and only one.

Dont use null, mention the view you send users who are not itil.

Here is an example you can refer to.

find_real_file.png

 

-Anurag

This is also not working. No luck!!!!!