- 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
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- 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');
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- 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
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- 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');
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 11:45 PM
Hi @Amit Gujarathi ,
Why on earth are you posting a script when he is asking for OOTB filter condition? There is no need to script when you can utilize OOTB functionality.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 11:47 PM
Hi @AndersBGS , My bad I just missed the filter ask in the query.
@chrifan Please refer the filter condition by Anders
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi