- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:22 AM
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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2018 07:06 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 04:09 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:30 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:39 AM
How should i modify the BR?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:43 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 05:56 AM
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.