- 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
‎01-31-2019 11:00 AM
This was helpful, thank you.
Only extra work that I needed to do is while this did allow end-users to see inactive users (my use case was for managers or their assistants to be able to request a "reactivation" of a user after being on leave for extended period of time: FMLA, paternity, maternity, etc.) was for a script include I had pulling in the users title, etc.
So the names did show in the list of users...BUT...when my onChange client script fired off the script include to populate back in the form the user's title, manager, etc. it would throw errors (Javascript errors on Portal and in back-end it would come back as undefined and lockup). So in my script include, I had to utilize:
.setWorkflow(false)
So example:
var userId = this.getParameter('sysparm_user_id');
var u = new GlideRecord('sys_user');
u.setWorkflow(false);
var uObj = {};
if (u.get(userId)) {
uObj = {
"title" : u.getValue('title')
Notice the GR query here...it was triggering the BR that blocks inactive users from showing and because it doesn't carry that encoded query of "activeANYTHING", it was hitting a wall, causing problems.
So I tested around trying to rewrite the script include to do a full query and add the encoded query, blah blah and it didn't work.
So...I just added in the flag u.setWorkflow(false);
And then let the rest continue as normal and this allowed me to get back the data I needed.
For those that don't know, using: .setWorkflow(false); prevents all business rules from running, pretty rare need for this, but this was one.
Obviously this post may not mean anything to most here, but for those who found this and then had a bit more to their use case, check out my post and see if it helps.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 11:59 AM
Hi Allen A,
We have a very similar requirement to reactive terminated contractors via a form in ServiceNow. This is a very good find, it helped populate the current User Record info on the client side, thank you for sharing.
One other challenge we are facing is when we are generating approvals for the manager of the contractor being reactivated, it errors out and I believe this is also due to the user query business rule blocking access for the user submitting the request (non-admin). Any idea on how to bypass the "user query" BR when doing a record lookup?
Thanks
Chris

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 02:17 PM
Hi,
Sorry, you didn't really provide any information as to how you're doing that record lookup, but if it's anything like what I've stated you'd use the whole: "current.setWorkflow(false);" or whatever variable you're using for your GlideRecord query, if that's how you're doing it. Using what I mentioned above bypasses the BR.
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2020 06:16 AM
Thank you so much !