- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 11:31 PM
Hi,
I'm want to how many Incidents triggered a Change Request and how many Incidents were triggered by a failed Change. How to build a suitable filter for this purpose? Thx
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 11:38 PM
Hi @chrifan ,
For "incidents triggered a change request" you can create a report based on the incident table with the condition:
For "incidents were triggered by a failed change" you can create a report based on the incident table with the condition:
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 11:43 PM
HI @chrifan ,
I trust you are doing great.
Please find the below code
// Get the current Change Request record
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(current.change_request)) {
// Count Incidents linked to this Change Request
var incidentCount = new GlideAggregate('incident');
incidentCount.addQuery('related_to', current.change_request);
incidentCount.addAggregate('COUNT');
incidentCount.query();
if (incidentCount.next()) {
// Display the count on the Change Request form
current.incidents_linked = incidentCount.getAggregate('COUNT');
}
// Count Incidents triggered by this Change Request and marked as Failed
var failedIncidentCount = new GlideAggregate('incident');
failedIncidentCount.addQuery('triggered_by', current.change_request);
failedIncidentCount.addQuery('state', 'Failed'); // Assuming the state field indicates failure
failedIncidentCount.addAggregate('COUNT');
failedIncidentCount.query();
if (failedIncidentCount.next()) {
// Display the count on the Change Request form
current.failed_incidents = failedIncidentCount.getAggregate('COUNT');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 12:54 AM
Thanks to you both,
@AndersBGS this was the direct way I wanted to, indeed. Thank you.
But the code snippet by @Amit Gujarathi could be helpful for the DevOps too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 02:26 AM
Hi @chrifan
Greetings!!
As a best practice, avoid script if possible. The solution is already provided by @AndersBGS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 09:28 PM
Greetings !!
Thanks for the hint.
I regard your code snippet as a backup solution, exit code, last man standing, ...
I appreciate best pratice, I do.
Very best regards
Chris F.