Automatically create problem when more than 4 incidents with same CI, category & subcategory values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2024 06:18 AM
Hi,
We are looking for a solution where system auto creates a problem ticket when there are more than 4 incidents are submitted for the same CI, Category and Subcategory combination , without redundancy.
Can this be achieved? Has anyone found a solution via Business rules or Flow Designer to achieve this? Need the solution run once every 10 days. Any suggestions or inputs please?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2024 11:32 AM
Hi @SanaPR
Try below BR:
var aggIncident = new GlideAggregate('incident');
aggIncident.addAggregate('COUNT');
aggIncident.addQuery('cmdb_ci', current.cmdb_ci);
aggIncident.addQuery('category', current.category);
aggIncident.addQuery('subcategory', current.subcategory);
aggIncident.query();
while (aggIncident.next()) {
if (aggIncident.getAggregate('COUNT') >= 4 && !aggIncident.problem_id) {
var prb = new GlideRecord('problem');
............
var prbID = prb.insert();
current.problem_id = prbID;
} else if (aggIncident.getAggregate('COUNT') >= 4 && aggIncident.problem_id) {
current.problem_id = aggIncident.problem_id;
} else {
return;
}
}
To create Problem record set values accordingly and try this it should work.
Or can try similar code in Scheduled Job if you want to achieve it using Scheduled Job.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2024 04:09 AM - edited ‎09-05-2024 05:20 AM
Thank you for your response. Appreciate it very much. There seems to be couple of issues with this that I could correct with below code. But is there a way to link these 4 incidents to this newly created problem ticket? Also since it is an Insert/Update BR, it creates a new Problem ticket every time there is an update on one of the Incident records, But I needed it update since the category/subcategory/CI values may change even after incident ticket submission. Is there a way to check if a problem already exists for an Incident while updating the ticket and ignore creation of new problem if there is already one created/related.
Thank you for your reply.
Corrected script for After Insert Update Business Rule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2024 12:09 PM
Hi @SanaPR
Yes, I just gave you sample where you can update details according to the requirement. To check Problem already exist or not also I added condition.
Do mark my answer as Correct if this helped you to resolved the issue.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 11:03 PM
sir, if my problem is close and then i got same CI issue so what should i do in that situation?