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

Alexandre Sing2
Kilo Expert

How can you acheive this please : "(in the BR you'd need to check where the user is accessing from)." ?

If you add ITIL to your BR you should update each catalog variable referecing sys_user with an active condition.

 

What is this catalog item supposed to acheive ? Is there no other way to deal with the customer's need than a catalog item ?

If you keep the user Active and lock him out he will still appear on the list. Would this do the trick ?

vicku1989
Tera Contributor

User below code to see inactive users for any specific catalog items. use this code in OOB BR (User Query)

(function executeRule(current, previous /*null when async*/) {

//used for the visibility of inactive users in particular items.
var cat_ids = gs.getProperty('property_name');//fetch catalog items sys_id
var cat_id_array = cat_ids.split(',');
var flag=false;
for(var i = 0; i < cat_id_array.length; i++) {
var cat_sysid=cat_id_array[i];
var catItem = GlideTransaction.get().getRequest().getHeader("referer").toString().indexOf(cat_sysid+'');
if(catItem!=-1){ //if the catalog item sysid present in query URL. -1 means no search result 
flag=true;
break;
}
}
if(flag) { }
else{
current.addActiveQuery();
}
})(current, previous);

 

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

 

Thanks Ryan!

ryanbalcom - Thank you very much for posting this solution.
 
I feel that this is the best solution as it only shows inactive users on that particular form variable.
 
Not really sure how setting the reference qualifier to Active is anything is heading back to activeANYTHING in the script but I have yet to complete all of the training materials on the developer site yet.
 
Nice help!