How can ITIL users see inactive users for one catalog item?

ServiceNow SA
Kilo Guru

Hi ,

Can anybody know , how can we show inactive users to ITIL users ?

I have a field referring to user table in Catalog item. When ITIL user is clicking on the reference field, he can only see list of active users. I need to show him inactive users as well but the global BR (user query) is restricting the visibility.

I need to show active users + inactive users only for this catalog item.

Let me know if anybody has worked on it.

1 ACCEPTED SOLUTION

ryanbalcom
Mega Expert

I've recently encountered the same situation. I solved the problem by setting the reference qualifier on the variable to "activeANYTHING". Inside the "User Query" business rule I do something similar to:

var query = current.getEncodedQuery()

if( gs.getSession().isInteractive() && !query.includes('activeANYTHING') )

current.addActiveQuery()

 

Hope this helps you or others. Same idea can be used to bypass other query rules. 

Ryan

Originally posted: https://community.servicenow.com/community?id=community_question&sys_id=e62347e1dbd8dbc01dcaf3231f9619d6

 

View solution in original post

23 REPLIES 23

Can you put some logging in there? It works on my dev instance fine. There might be an error being thrown if it's returning nothing - maybe check the logs for errors. I've updated the script below to include debug statements



var restrictQuery = true;


var variableName = "IO:66c334eac0a8016b017e6affe311ebb6"; //change the sysid here for the sysid of the variable you don't want it to be restricted for




if (gs.hasRole("itil")) {


gs.log(gs.getUserName() + " has itil", "querydebug");


var map = gs.action.getGlideURI().getMap();


gs.log("map: " + map.toString() + " sysparmname: " + map.get('sysparm_name'), "querydebug");


if (map.get('sysparm_name') != null && map.get('sysparm_name') == variableName) {


restrictQuery = false;


}


}


gs.log("Restrict query was set to: " + restrictQuery);



if (restrictQuery) {


current.addActiveQuery();


}


Ahmed Hmeid1
Kilo Guru

Hi,



Making it visible only on that one catalog item is possible with additional code (in the BR you'd need to check where the user is accessing from).



Easier solution would be to make inactive users visible to itil users from that business rule.


How should i modify the BR?


Hi Sri,



As mentioned in my earlier comment add that condition and test it once whether it shows both active and inactive users. That business rule should not execute for itil user role.



Regards


Ankur


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

Hi Ankur,



After making that change, yes user can see both inactive + active users.



But it will lead the itil users to see inactive users everywhere , for other catalog items as well. I do not want that to happen.   I only want ITIL user to see inactive users for one catalog item only.