Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 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
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,37 @@
Key features
Automatic problem creation: The script uses a GlideAggregate query to count the number of incidents opened for a specific CI.
Time-based threshold: Problems are only created if more than five incidents are opened within a 60-minute window.
Targeted incidents: The script focuses on incidents related to the same CI, making it effective for identifying recurring infrastructure issues.
Customizable conditions: The number of incidents and the time frame are easily configurable within the script.
Efficient performance: The use of GlideAggregate ensures the database is queried efficiently, minimizing performance impact.

How it works
The script is designed to be executed as a server-side script, typically within a Business Rule. When an incident is inserted or updated, the script performs the following actions:
Queries incidents: It executes a GlideAggregate query on the incident table.
Sets conditions: The query is filtered to count all incidents that meet the following conditions:
Same CI: The incident's cmdb_ci matches the cmdb_ci of the current record.
Within the last hour: The opened_at time is within the last 60 minutes.
Evaluates count: After the query is run, the script checks if the count of matching incidents exceeds the threshold (in this case, 5).
Creates problem: If the threshold is exceeded, a new problem record is initialized.
The short_description is automatically populated with a descriptive message.
The cmdb_ci is linked to the new problem record.
The new record is then inserted into the database.
Implementation steps
Create a Business Rule:
Navigate to System Definition > Business Rules.
Click New.
Configure the Business Rule:
Name: Auto Create Problem from Multiple Incidents
Table: Incident [incident]
Advanced: true
When to run: Select after and check the Insert and Update checkboxes. This ensures the script runs after an incident has been saved.
Filter conditions: Optionally, you can add conditions to limit when the script runs (e.g., cmdb_ci is not empty).
Add the script:
Navigate to the Advanced tab.
Copy and paste the script into the Script field.
Customize (optional):
Number of incidents: Change the > 5 value to adjust the threshold.
Time frame: Adjust the gs.minutesAgoStart(60) value to change the time window.
Other conditions: If you need to check for specific incident statuses or categories, add more addQuery lines to the GlideAggregate call.
Save the Business Rule.
Customization examples
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var incidentCheck = new GlideAggregate('incident');
incidentCheck.addQuery('cmdb_ci', current.cmdb_ci); // Or any specific CI
incidentCheck.addQuery('opened_at', '>', 'javascript:gs.minutesAgoStart(60)');
incidentCheck.addAggregate('COUNT');
incidentCheck.query();

if (incidentCheck.next() && parseInt(incidentCheck.getAggregate('COUNT')) > 5) {
var problem = new GlideRecord('problem');
problem.initialize();
problem.short_description = 'Multiple incidents reported for CI: ' + current.cmdb_ci.getDisplayValue();
problem.cmdb_ci = current.cmdb_ci;
problem.insert();
}
Loading