This utility is designed for ServiceNow administrators to help maintain user accounts by automatically deactivating users who have not logged in for a specified number of days. It's a Script Include that can be scheduled to run at regular intervals or executed manually.
- Identifies users who have been inactive for a given number of days.
- Deactivates these users to keep the user list current and secure.
- Logs all deactivation actions for auditing purposes.
Before you begin using this utility, ensure that you have the necessary permissions to modify user records in ServiceNow.
- Navigate to
System Definition > Script Includes
in your ServiceNow instance. - Click on
New
to create a new Script Include. - Give it a name, such as
InactiveUserCleanup
. - Copy and paste the code from the
InactiveUserCleanup.js
file into theScript
field. - Save the new Script Include.
To use the InactiveUserCleanup
utility:
- Create an instance of the
InactiveUserCleanup
class in a background script, business rule, or scheduled job. - Call the
deactivateInactiveUsers
method with the number of days of inactivity as the parameter.
Example for a background script:
var cleanup = new InactiveUserCleanup();
cleanup.deactivateInactiveUsers(90); // Deactivate users who have been inactive for 90 days