You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Role Usage Analyzer (Audit-Based) for ServiceNow
2
+
3
+
## Overview
4
+
5
+
This script analyzes role assignments and identifies roles that may be unused by checking user activity in the `sys_audit` table. It focuses on recent activity (last 90 days) to determine whether users assigned to a role have interacted with the system.
6
+
7
+
## Features
8
+
- Uses `sys_audit` for accurate activity tracking
9
+
- Filters audit records from the **last 90 days** to reduce data volume
10
+
- Flags roles assigned to users who show **no audit activity**
11
+
- Logs potentially unused roles with user count
12
+
13
+
## Usage
14
+
15
+
1. Navigate to **System Definition > Script Includes** or **Scheduled Script Executions**.
16
+
2. Create a new Script Include or Scheduled Job named `Role_Usage_Analyzer_Audit`.
17
+
3. Paste the contents of `Role_Usage_Analyzer_Audit.js` into the script field.
18
+
4. Run manually or schedule it to run periodically (e.g., monthly).
19
+
20
+
## Notes
21
+
22
+
- The script uses `gs.daysAgo(90)` to limit the audit data to recent activity.
23
+
- You can adjust the time window by changing the `gs.daysAgo()` value.
24
+
- Consider extending the script to generate reports or notify role owners for cleanup.
0 commit comments