Category/Subcategory to load based on user roles

Not applicable

I'm sure there's a way to do this, but can't figure it out...so here I am posting...

I'd like to have certain categories and subcategories on the incident form visible to specific users for routing purposes. Is there a way to set categories/subcategories to show based on user roles?

6 REPLIES 6

Mark Stanger
Giga Sage

You can do this using client scripting. Take a look at the following wiki article. There are examples there on how to check for a specific role and how to remove options from a choice list.

http://wiki.service-now.com/index.php?title=Client_Scripts


john_walsh
ServiceNow Employee
ServiceNow Employee

Domain Separation would allow you to accomplish that. Obviously complicates things though in other areas though...


brozi
ServiceNow Employee
ServiceNow Employee

Mark

this may give you a start. It is a client script that will check if the user has role of admin or itil. The only issue is you have to then maintain a script as you update, but it would work. See if anyone has a cleaner way..


function onLoad() {
var isITIL = g_user.hasRole('itil');
var isAdmin = g_user.hasRole('admin');

if (isAdmin){ //return if admin and allow all fields
return true;
} else {
if (isITIL){ // if itil remove hardware
g_form.removeOption('category', 'hardware');
}
}
}


CapaJC
ServiceNow Employee
ServiceNow Employee

Only with client script, I believe:
http://wiki.service-now.com/index.php?title=Client_Scripts#Test_if_the_current_user_has_a_role
http://wiki.service-now.com/index.php?title=Client_Scripts#Remove_an_Option_from_a_Choice_List

You'd test for a role, then add/remove choice list options based on the user's roles.

Easy for category, but for subcategory it might get tedious to script! Maybe someone else has a better solution.