How to add incident-task to incident record through business rule?

kgomez222
Tera Contributor

Hey, I need to create an incident-task record in response to an incident being created with critical priority.

so far this is my script and it doesn't seem to be inserting anything into the related list of incident task. 

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

try {
var incidentTask = new GlideRecord('incident_task');
incidentTask.initialize();
incidentTask.short_description = 'This critical incident has been submitted involving your team member. Close this ask as a sign of acknowledgment';
incidentTask.parent = current.sys_id;
incidentTask.assigned_to = current.caller_id.manager;
incidentTask.incident = current.number;
incidentTask.insert();
} catch (error) {
gs.log(error + 'test');
}
})(current, previous);

kgomez222_0-1669661338601.png

Nothing is being populated here. 

 

1 ACCEPTED SOLUTION

Ishaan Shoor
Mega Sage
Mega Sage

Hi, 

I've updated your script please try now.

 

 

 

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

var incidentTask = new GlideRecord('incident_task');
incidentTask.initialize();
incidentTask.short_description = 'This critical incident has been submitted involving your team member. Close this ask as a sign of acknowledgment';
incidentTask.parent = current.sys_id;
incidentTask.assigned_to = current.caller_id.manager;
incidentTask.incident = current.sys_id;
incidentTask.insert();

})(current, previous);

 

 

 


.

Hope this helps!
BR.
Ishaan Shoor

View solution in original post

6 REPLIES 6

Hi @kgomez222 

Please find attached the Business rule XML record, do update your when to run and conditions in the BR.


Hope this helps!
BR.
Ishaan Shoor

Thank you ishaan! it works! appreciate the help