Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2da9254
script.js
trimbakeshmadhan-109 Oct 27, 2025
c9315ec
README.md
trimbakeshmadhan-109 Oct 27, 2025
5d17de8
Script.js
trimbakeshmadhan-109 Oct 27, 2025
c8c2e06
README.md
trimbakeshmadhan-109 Oct 27, 2025
14244d8
script.js
trimbakeshmadhan-109 Oct 27, 2025
45c645d
README.md
trimbakeshmadhan-109 Oct 27, 2025
3edf0bc
Update README.md
trimbakeshmadhan-109 Oct 27, 2025
fa78c36
script.js
trimbakeshmadhan-109 Oct 27, 2025
a6e23bd
README.md
trimbakeshmadhan-109 Oct 27, 2025
484bcdd
Update script.js
trimbakeshmadhan-109 Oct 27, 2025
12f9ba9
Delete Core ServiceNow APIs/GlideAggregate/Count Inactive Users with …
trimbakeshmadhan-109 Oct 28, 2025
23f8bb3
Delete Core ServiceNow APIs/GlideAggregate/Count Inactive Users with …
trimbakeshmadhan-109 Oct 28, 2025
75d8c0b
Delete Core ServiceNow APIs/GlideAggregate/Find oldest Incident based…
trimbakeshmadhan-109 Oct 28, 2025
4f13513
Delete Core ServiceNow APIs/GlideAggregate/Find oldest Incident based…
trimbakeshmadhan-109 Oct 28, 2025
5328dda
Delete Core ServiceNow APIs/GlideJsonPath/GlideJsonPath Reader Exampl…
trimbakeshmadhan-109 Oct 28, 2025
6750b61
Delete Core ServiceNow APIs/GlideJsonPath/GlideJsonPath Reader Exampl…
trimbakeshmadhan-109 Oct 28, 2025
ab49a77
script.js
trimbakeshmadhan-109 Oct 28, 2025
97dded4
README.md
trimbakeshmadhan-109 Oct 28, 2025
eb2affb
Delete Client-Side Components/Client Scripts/Count Inactive Users wit…
trimbakeshmadhan-109 Oct 28, 2025
a260097
Delete Client-Side Components/Client Scripts/Count Inactive Users wit…
trimbakeshmadhan-109 Oct 28, 2025
4a9be5b
README.md
trimbakeshmadhan-109 Oct 29, 2025
216ca01
script.js
trimbakeshmadhan-109 Oct 29, 2025
ab9344d
README.md
trimbakeshmadhan-109 Oct 29, 2025
73b6749
Create script.js
trimbakeshmadhan-109 Oct 29, 2025
62da5ec
Delete Server-Side Components/Server Side/Count Inactive Users with A…
trimbakeshmadhan-109 Oct 29, 2025
55d67d2
Delete Core ServiceNow APIs/GlideAggregate/Create Problem based on in…
trimbakeshmadhan-109 Oct 29, 2025
5e5531b
Delete Core ServiceNow APIs/GlideAggregate/Create Problem based on in…
trimbakeshmadhan-109 Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Count Active Incidents Assigned to Inactive Users

This script uses GlideAggregate to efficiently count the number of active incidents assigned to inactive users.

This is a crucial task for maintaining data hygiene and preventing incidents from being stalled due to inactive assignees.

Overview The script performs the following actions: Initializes GlideAggregate: Creates an aggregate query on the incident table.

Filters Records: Uses addQuery() to restrict the search to incidents that are both active (true) and assigned to a user whose active status is false.

This filter uses a "dot-walk" on the assigned_to field to check the user's active status directly within the query.

Aggregates by Count: Uses addAggregate() to count the number of incidents, grouping the results by assigned_to user.

Executes and Logs: Runs the query, then loops through the results.

For each inactive user found, it logs their name and the number of active incidents assigned to them. Use case This script is essential for regular cleanup and maintenance.

It can be used in: Scheduled Job: Automatically run the script daily or weekly to monitor for and report on incidents assigned to inactive users.

Installation As a Scheduled Job Navigate to System Definition > Scheduled Jobs.


Click New and select Automatically run a script of your choosing. Name the job (e.g., Find Incidents Assigned to Inactive Users).


Set your desired frequency and time. Paste the script into the Run this script field. Save and activate the job. As a Fix Script Navigate to System Definition > Fix Scripts.

Click New. Name it (e.g., Find Active Incidents with Inactive Assignee).


Paste the script into the Script field. Run the script to see the results in the System Log.


Customization Targeted tables: Change the table name from incident to task or any other table with an assigned_to field to check for active records assigned to inactive users.


Automated reassignment: Extend the script to automatically reassign the incidents to a group or another user. This is a common practice to ensure that tickets do not get stuck in the queue. Email notification: Instead of logging the information, modify the script to send an email notification to the group manager or another stakeholder with the list of incidents needing attention.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
This script uses GlideAggregate to find the number of active incidents
that are assigned to users who are currently marked as inactive.
GlideAggregate is used instead of a standard GlideRecord query
because it is more efficient for performing calculations like COUNT
directly in the database.
*/
var ga = new GlideAggregate('incident');

// Query for active incidents.
ga.addQuery('active', true);

// Use dot-walking to query for incidents assigned to inactive users.
ga.addQuery('assigned_to.active', false);

// Add an aggregate function to count the incidents, grouped by the assigned user.
ga.addAggregate('COUNT', 'assigned_to');

// Execute the query.
ga.query();

// Process the results of the aggregate query.
while (ga.next()) {
// Get the display name of the inactive user from the current record.
var inactiveUser = ga.assigned_to.getDisplayValue();

// Get the count of active incidents for this specific user.
var incidentCount = ga.getAggregate('COUNT', 'assigned_to');

// Log the result to the system logs.
gs.info("Inactive user " + inactiveUser + " has " + incidentCount + " active incidents.");
}
Loading