create 5 incident tasks when a incident is create

Payal Tripathy
Tera Contributor

When category, subcategory, item , and summary are customer, capacity, no action taken, and customer it should automatically create 5 incident tasks.

 
2 REPLIES 2

Keshav07
Mega Guru

Hi @Payal Tripathy ,

 

You can create a business rule (after) with your own conditions.

Keshav07_0-1715357790430.png

 

You can use the below script :

 

(function executeRule(current, previous /*null when async*/ ) {

    var incidentGR = new GlideRecord("incident_task");
    for (var i = 0; i < 5; i++) {
        incidentGR.initialize();
        incidentGR.incident = current.sys_id;
        incidentGR.short_description = current.short_description;
        incidentGR.description = current.description;
        incidentGR.assignment_group = current.assignment_group;
        incidentGR.assigned_to = current.assigned_to;
        incidentGR.cmdb_ci = current.cmdb_ci;
        incidentGR.insert();
    }

})(current, previous);
 
If you find this helpful, Kindly accept this solution.
 
Thank you!

 

 

Community Alums
Not applicable

Hi @Payal Tripathy ,

Please create Before Business Rule and add below code 

    var count = 5
    gs.log("Inside BR");
    var incTaskGR = new GlideRecord("incident_task");
    for (var i = 0; i < count; i++) {
        incTaskGR.initialize();
        incTaskGR.incident = current.sys_id;
        incTaskGR.cmdb_ci = current.cmdb_ci;
        incTaskGR.description = current.description;
        incTaskGR.short_description = current.short_description;
        incTaskGR.assigned_to = current.assigned_to;
        incTaskGR.assignment_group = current.assignment_group;
        incTaskGR.assigned_to = current.assigned_to;
        incTaskGR.insert();
    }

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak