Reference to sys_user only active users for all fields

Henrik Jutterst
Tera Guru

Hello community!

 

Is there a way to only reference active users in ServiceNow from the GUI? I recently saw that we had some duplicate users based on email address. I then updated the duplicate email address and set the active flag to false.

For example. In an incident form I should only be able to search for users that have the active flag to true in sys_user table.

Can this be set on a global level somewhere in a properties file so I don't have to edit all the forms that have reference to sys_user table.

 

Kind regards

/Henrik

1 ACCEPTED SOLUTION

Hi Henrik,

 

Above script is an out of box script which will display only active user records for non-admins.

 

Regards,

Ram M

View solution in original post

8 REPLIES 8

Hi Henrik,

 

If you don't want the active users to be displayed for admins as well then you can remove the below condition from the condition field

&& !gs.hasRole("admin")

But issue is that you will not be able to see the inactive records in case of any debugging to be done for inactive accounts.

 

Regards,

Ram M

 

 

Anurag Tripathi
Mega Patron
Mega Patron

I would suggest not doing it on a global way as you are trying, instead on the incident form you use a reference qualified to query only active records. 

If you do it on a global level you will have to add exceptions everything someone needs to look at the inactive records(report, audits etc).

 

Generally as a good practice also for querying any query we try and add active clause to get smaller and refined record set, user or any other table.

-Anurag

how would you find all the places that the sys_user table is referenced? Incident, request, etc....

 

One way could be Dictionary.

Type Reference and referenced table  :- User

This is an old thread, haven't checked the whole thing 🙂

-Anurag