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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sri,



One thing you can do is.


Modify business rule condition so that it doesn't run for itil user.


But this will be a global impact.



Current condition:


gs.getSession().isInteractive() && !gs.hasRole("admin")



Modified Condition:


gs.getSession().isInteractive() && !gs.hasRole("admin") && !gs.hasRole("itil")



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

But i dont want it to be a global impact. I want for that particular form.


If you only want it on a specific variable then you can update the business rule to be:



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")) {


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


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


restrictQuery = false;


}


}




if (restrictQuery) {


current.addActiveQuery();


}


Hi Ahmed,



Nothing is getting displayed if i update BR(user query) as per your code. Also this is getting applicable globally, not getting restricted to only this variable.