Create Multiple Child Incident

naga karthik1
Tera Contributor

Hello All,  

I have a requirement to make an Incident as parent Incident automatically while creating it and to define multiple child Incidents(say more than 15) with different assignment group and caller automatically with same remaining field values. All these should happen when a user checks a check box "Special Security Incident" on Incident form. 

 

I have tried writing a after insert BR which will run on checking the special security incident check box on incident form.

for initial testing I have written code for 3 child incidents, but still no child incidents were created.

CODE:

 

(function executeRule(current, previous /*null when async*/ ) {
    //var parent_inc = current.getUniqueValue();
    var currentsysID = current.getUniqueValue();
    gs.log("check parent incident:" + currentsysID.toString());

    for (var i = 0; i < 3; i++) {
        if (i == 0) {
            var gr = new GlideRecord("incident");
            gr.initialize();
            gr.parent_incident = currentsysID;
            gr.category = current.category;
            gr.subcategory = current.subcategory;
            gr.caller_id = '0e4070a74f2ba2006ff669d18110c776';
            gr.state = current.state;
            gr.assignment_group = '2207520387850d10f4b562083cbb354a';
            gr.short_description = current.short_description;
            gr.description = current.description;
            gr.priority = current.priority;
            gr.impact = current.impact;
            gr.urgency = current.urgency;
            gr.state = current.state;
            gr.insert();
            gs.log("first child incident is successfully created--------------------->");
        }

else if (i == 1) {
            var gr1 = new GlideRecord("incident");
            gr1.initialize();
            gr1.parent_incident = currentsysID;
            gr1.category = current.category;
            gr1.subcategory = current.subcategory;
            gr1.caller_id = '4b6934201b168d10f300edb1b24bcbf8';
            gr1.assignment_group = '591221f01bd20d109570a71ee54bcb58';
            gr1.state = current.state;
            gr1.short_description = current.short_description;
            gr1.description = current.description;
            gr1.priority = current.priority;
            gr1.impact = current.impact;
            gr1.urgency = current.urgency;
            gr1.state = current.state;
            gr1.insert();
            gs.log("second child incident is successfully created--------------------->");
        }

else if (i == 2) {
            var gr2 = new GlideRecord("incident");
            gr2.initialize();
            gr2.parent_incident = currentsysID;
            gr2.category = current.category;
            gr2.subcategory = current.subcategory;
            gr2.caller_id = '2e47fda6dbd12bc8de62384c7c961919';
            gr2.assignment_group = 'e3f73f061be189109570a71ee54bcb5f';
            gr2.state = current.state;
            gr2.short_description = current.short_description;
            gr2.description = current.description;
            gr2.priority = current.priority;
            gr2.impact = current.impact;
            gr2.urgency = current.urgency;
            gr2.state = current.state;
            gr2.insert();
            gs.log("third child incident is successfully created--------------------->");
        }

    }

})(current, previous);

 

Can anyone please guide where it is going wrong.

5 REPLIES 5

Mark Manders
Mega Patron

Isn't it easier to use Major Incident Management for this?

If my answer helped you in any way, please then mark it as helpful.

Mark


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Arav
Tera Guru
Tera Guru

a. Please troubleshoot in small steps

b. Remove the "for" loop and retain only the first snippet (i.e. create 1 child incident)

c. Turn on Debug Business Rule and check if the BR is executed or skipped when the parent incident is created

d. Please also add a screenshot of the "When to Run" page of the BR here. I hope there are no additional conditions added on top of "special security incident check box"

Hello Arav,

Yes, the business rule is executing and 1 child incident is created when parent is created if we remove and for loop.

There is only one condition in when to run, i.e., "special security incident check box" should be true. PFA screenshot for the same.find_real_file.png

naga karthik1
Tera Contributor

Hello Arav,

Yes, the business rule is executing and 1 child incident is created when parent is created if we remove and for loop.

There is only one condition in when to run, i.e., "special security incident check box" should be true. PFA screenshot for the same.