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

German Alvarez2
Tera Expert

Does it have any sense to short-circuit que inactive user BR?



I mean... Users has almost two controls attached, Active and Locked Out. From my low knoledge, Active register is the way to not delete registers in tables, saving the data, for reposrts, or only as a history base, but inactive registers are non intended to be used from the moment they are marked as inactive.



In the other hand, we need to work with users registers in our system, so, they should be active, but we don't want this users to log into the instance, so there is "Locked Out" registers to solve our problem...



So, working with both flags, I don't know the reason for select a user marked as "non-active" and I think that "Locked Out" was a very great idea to deal with this "contradictory requirements" that day by day we have to deal with.



As a resume, my Answer is, work with "Locked out" and "Active" in order to separate next two concepts:


- Block the access to a user


- Delete the user, without any lose of information



Best Regards