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

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

Hello Ishaan, i am still not seeing an incident task populating the related incident task list. Not sure if its working. 

Actually, it looks like the incident task has actually been created when I navigate to 'incident_task.list' with the system navigator.

is there a way i could make it show up in the related lists section within the same incident form? 

No worries, let me share a BR XML record for you.

Hope this helps!
BR.
Ishaan Shoor