- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 03:25 AM
Hi Everyone,
I have a requirement to create a problem record when major incident is Resolved. So i wrote a after business rule with condition incident state is resolved and Priority is 1. Here is the script i wrote. This is working for all incidents. This should only work for Major Incidents. How can i change this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 04:13 AM - edited 04-03-2024 04:17 AM
Hi @Atchutaram,
A couple of tweaks for your Business Rule to cater for potential future state changes (If the incident is moved to the 'Resolved' state more than once and checking that a problem record hasn't already been created)
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
Script update:
var shortdes = current.short_description;
var assignment = current.assignment_group;
var prob = new GlideRecord('problem');
prob.short_description = shortdes;
prob.assignment_group = assignment;
var newProblemRecord = prob.insert();
gs.addInfoMessage(prob.number + "Problem ticket has been created through Incident Record");
//Update relationship between newly created Problem and Major Inc
var incGR = new GlideRecord('incident');
incGR.addQuery('sys_id', current.sys_id);
incGR.query();
if (incGR.next()) {
incGR.problem_id = newProblemRecord;
incGR.update();
}
Config update to the Business Rule ('When to run tab' - please note the change to 'after'. You can also adjust this filter how you see fit, eg Priority values etc. The conditions need to be met in order to run)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 03:34 AM
Hello @Atchutaram ,
To ensure that the problem record creation only happens for major incidents, you need to include a condition to check if the incident is a major incident before creating the problem record. You can do this by checking the incident's category or any other field that distinguishes major incidents from regular incidents.
Thanks
Abhijeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 03:46 AM - edited 04-03-2024 03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 03:46 AM
Hi @Atchutaram ,
Try this one,
var shortdes = current.short_description;
var assignment = current.assignment_group;
if (current.priority == 1 && current.state == 6 /*You can add the exact condition whatever that says the record is Major Incident.*/) {
var prob = new GlideRecord('problem');
prob.short_description = shortdes;
prob.assignment_group = assignment;
prob.insert();
gs.addInfoMessage(prob.number + " Problem ticket has been created through Incident Record");
}
Regards,
Dhanraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 04:13 AM - edited 04-03-2024 04:17 AM
Hi @Atchutaram,
A couple of tweaks for your Business Rule to cater for potential future state changes (If the incident is moved to the 'Resolved' state more than once and checking that a problem record hasn't already been created)
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.
Thanks, Robbie
Script update:
var shortdes = current.short_description;
var assignment = current.assignment_group;
var prob = new GlideRecord('problem');
prob.short_description = shortdes;
prob.assignment_group = assignment;
var newProblemRecord = prob.insert();
gs.addInfoMessage(prob.number + "Problem ticket has been created through Incident Record");
//Update relationship between newly created Problem and Major Inc
var incGR = new GlideRecord('incident');
incGR.addQuery('sys_id', current.sys_id);
incGR.query();
if (incGR.next()) {
incGR.problem_id = newProblemRecord;
incGR.update();
}
Config update to the Business Rule ('When to run tab' - please note the change to 'after'. You can also adjust this filter how you see fit, eg Priority values etc. The conditions need to be met in order to run)