Showing all users in a Reference variable

ewilks
Giga Expert

I have a variable set that includes a reference to User [sys_user].   I would like to list all users (active and not active) on certain Configuration Items.   The default is to only display active.   How do I code to include all users?

By the way, when I'm logged in as admin, I can see all users regardless as to whether the records are active or not, but as a normal user, just active users show on the list.

 

I tried to add the below code to the onLoad Script, but it doesn't work.  

 

    var guidename = g_form.getValue('name');

    if(guidename == 'MW Termination'){

    g_form.refQual('requested_for','active in (true,false)');

    }

1 ACCEPTED SOLUTION

Jake Gillespie
Mega Guru

Hi Eric,



As Kalaiarasan P said, there is a Before "Query" business rule called "user query" with the following code:


current.addActiveQuery();



This is a standard BR created by ServiceNow, and it should not be modified, else it will be excluded from future upgrades. I recommend marking it inactive (Active=false), and then copying the BR and modifying it to suit your purpose (you could add an additional gs.hasRole("xxx") condition if your intended users have a specific role). Otherwise, if you want end users (ESS) to see all users, you would just need to deactivate the BR.



Regards,


Jake


View solution in original post

5 REPLIES 5

Kalaiarasan Pus
Giga Sage

There is a display business rule on sys_user table that removes the inactive user. You would need to Change that.


this BR "user query"....


Jake Gillespie
Mega Guru

Hi Eric,



As Kalaiarasan P said, there is a Before "Query" business rule called "user query" with the following code:


current.addActiveQuery();



This is a standard BR created by ServiceNow, and it should not be modified, else it will be excluded from future upgrades. I recommend marking it inactive (Active=false), and then copying the BR and modifying it to suit your purpose (you could add an additional gs.hasRole("xxx") condition if your intended users have a specific role). Otherwise, if you want end users (ESS) to see all users, you would just need to deactivate the BR.



Regards,


Jake


Thanks Jake.   That's what I'm looking for .   I appreciate the warning on how my changing this will be overwritten next update.