Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Auto delete incident task when selected affected location is de-selected onrelated list of incident

Community Alums
Not applicable

Hi, I have a requirement whereend user select the affected location(cmn_location), incident task will be generated automatically through BR under the related list of incident. once incident task is closed complete, tax expense line(fm_expense_line) will be genaretd.Now, when user de-select the same affected location, it should delete already generated incident task also expense line so that sum of expense line will be calculated correctly.

 

BR: async ( insert - true)

table : affacted location

condition : task type is incident

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

    // Add your code here
    var incTask = new GlideRecord('incident_task');
    incTask.initialize();
    incTask.location = current.location.getValue();
    incTask.incident = current.task.getValue();
    incTask.short_description = 'Add Downtime to- ' + current.location.getDisplayValue();
    incTask.assignment_group = current.task.assignment_group.getValue();
    incTask.assigned_to = current.task.assigned_to.getValue();
    incTask.cmdb_ci = current.task.cmdb_ci.getValue();
    incTask.insert();

})(current, previous);
 
Any help on this really appreciated.
 
Thanks,
Abhishek
0 REPLIES 0