show inactive users records in catalog

Harish27
Kilo Guru

Hi,

I have a field Requested on Behalf on a catalog item which is a reference field to the sys_user table. By default, we will be able to see only active users in the Requested field, But I also want to see inactive users in the requested field.

1. One solution for this is to give the user_admin role to a particular user(not the best solution though) and we are not allowed to modify the OOTB business rule as well.

I heard that some business rule is locking the user session to only show active records.. Don't know much abt that.

 

So how we achieve this? Any help would be massively appreciated..

Thanks!!

1 ACCEPTED SOLUTION

Harish27
Kilo Guru

Thank you ankur and jaspal. I have written and article on this https://community.servicenow.com/community?id=community_article&sys_id=e2f2878bdbd4ec1011762183ca961... . This solves my requirement.

View solution in original post

18 REPLIES 18

Thanks. Try below,

var url = gs.action.getGlideURI().toString();
var index = url.toString().indexOf('sys_id=7cb65753db051010dd0a5fc74b961950')>-1;

if (index == false) {
    current.addActiveQuery();
}

Hi Jaspal,

 

It's not working.

 

Thanks!

For me it works well on portal view as well & version is NewYork.

Anways, you can use below.

1. Variable as below.

find_real_file.png

 

2. Update business rule code as below with condition as

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

var query = current.getEncodedQuery();
if( gs.getSession().isInteractive() && !query.includes('activeANYTHING') )
{
current.addActiveQuery();
}

3. Make sure you check Setp 2 as non-admin user as for admins the condition is excluded.

 

Tested the same in PDI & works well.

Hi,

the above would work in native view; for handing in portal some other approach would be required.

this line would lead to issue in portal

var url = gs.action.getGlideURI().toString();

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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