When Major incident is closed Problem ticket should be created.

Atchutaram
Tera Contributor

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?

 

 var shortdes = current.short_description;
    var assignment = current.assignment_group;

    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");
 
 
Thanks in advance.

 

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

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)

Screenshot 2024-04-03 at 12.09.13.png

 

View solution in original post

4 REPLIES 4

Abhijeet_Pawar
Tera Guru

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

Hello @Atchutaram ,

Refer below screenshot.

I hope this will resolve your issue.

Thanks 

Abhijeet.

dhanrajb
Tera Guru

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.

Robbie
Kilo Patron
Kilo Patron

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)

Screenshot 2024-04-03 at 12.09.13.png