Auto Create Case Task from Case field value

MStritt
Tera Guru

Hello,

I would like to auto create a case task with certain field values (and it be auto saved), when a specific field is populated on the case. The field on the case (checkbox) will be auto checked when a specific update is automatically added to the activity stream of the case.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Add this code and check-

var lastComments = current.comments.getJournalEntry(1);
if(lastComments.indexOf('The customer called and requested a callback') > -1){
var childTask = new GlideRecord('sn_customerservice_task');
childTask.initialize();
childTask.assignment_group = "ff0370019f22120047a2d126c42e702b"; // replace the sys_id with sys_id of the group
childTask.parent = current.sys_id;
childTask.short_description = "Child Task Test";
childTask.insert();
}

 

I tried this on my PDI and it works:

 

Case:

find_real_file.png

 

Case Task:

 

find_real_file.png

View solution in original post

18 REPLIES 18

Community Alums
Not applicable

Add this code and check-

var lastComments = current.comments.getJournalEntry(1);
if(lastComments.indexOf('The customer called and requested a callback') > -1){
var childTask = new GlideRecord('sn_customerservice_task');
childTask.initialize();
childTask.assignment_group = "ff0370019f22120047a2d126c42e702b"; // replace the sys_id with sys_id of the group
childTask.parent = current.sys_id;
childTask.short_description = "Child Task Test";
childTask.insert();
}

 

I tried this on my PDI and it works:

 

Case:

find_real_file.png

 

Case Task:

 

find_real_file.png

Case task still not being created. Here's the script.  Does it look OK? Syntax, etc.?

find_real_file.png

Here's what the comment looks like when it is added to the Case:

find_real_file.png

OK. I just used your script, and it worked.

find_real_file.pngNow I need to configure the script to add the 'Reason for Escalation' (u_escalation_reason_1) to be 'Callback'. And, the Priority to be '2 - High'. Also, it automatically added the 'Assigned To' as the same person that's assigned to the case. I need this to be blank/empty.

Hello,

I got it working 🙂 Here's the code:

var lastComments = current.comments.getJournalEntry(1);
if(lastComments.indexOf('The customer called and requested a callback') > -1){
var childTask = new GlideRecord('sn_customerservice_task');
childTask.initialize();
childTask.assignment_group = "5a9dc5193734a600cc47261953990ebd"; // replace the sys_id with sys_id of the group
childTask.parent = current.sys_id;
childTask.short_description = "Callback requested";
childTask.priority = 2;
childTask.u_escalate_reason_1 = 'Callback';
childTask.assigned_to = 'NULL';
childTask.insert();
}
})(current, previous);