Business Rule for updating child task when parent record gets updated

Dipali Pawar2
Tera Contributor

Hi, we are working on SLA related to task , when the parent case state is awaiting info we need to set the SLA for related case task to 'Paused' state. 

since only the case record is getting updated with the state the SLA for case task remains unchanged. 

with the update to any field in the case task record we are able to see the correct state of SLA .

so to update the case task we have written a business rule to update the work notes, below is the script 

DipaliPawar2_0-1674131240351.png

DipaliPawar2_0-1674131450640.jpeg

we are not able to see any update in case task record , please let us know what are we missing here.

Thanks in advance 

4 ACCEPTED SOLUTIONS

Omkar Ranjane
Tera Guru

Hi @Dipali Pawar2 

 

Create Before Update Business Rule with condition state changes to awaiting info or state changes to open & try below code snippet.

 

(function executeRule(current, previous /*null when async*/ ) {
    var caseTask = new GlideRecord("sn_customerservice_task");
    caseTask.addQuery("parent", current.sys_id);
    caseTask.query();
    while (caseTask.next()) {
        caseTask.work_notes = "Testing";
        caseTask.update();
    }
})(current, previous);

 

 

If your question is solved, please close the topic by marking my answer "Accept as Solution". This will help others searching for a similar question and will remove the topic from the unsolved list.

 

View solution in original post

kalyan13
Tera Guru

Hi @Dipali Pawar2 ,

Please try @Omkar Ranjane  solution, if you still unable to get the solution let me know 

Regards,

Kalyan 

View solution in original post

Hello @Omkar Ranjane .

Thanks for the code, worked like a charm!

I have a similar requirement and the case task is getting updated on change of state. One additional implementation which we are looking is to get the current state of the parent case.

I tried using 

current.top_task.getDisplayValue('state');

current.parent.getDisplayValue('state');

 

Both are bringing undefined value, Kindly help on this

Below is the script and screen shot:

 

Gokul24_0-1674303442741.png

 

 

(function executeRule(current, previous /*null when async*/ ) {
var caseTask = new GlideRecord("sn_customerservice_task"); //Gliding Case Task
caseTask.addQuery("parent", current.sys_id); //Checking if Case task has parent
caseTask.query();
while (caseTask.next()) { //if case task exist , updating work notes
var parent_case_state =current.top_task.getDisplayValue('state');
caseTask.work_notes = "Case State updated to" + parent_case_state;
caseTask.update();
}
})(current, previous);

View solution in original post

Hello @Omkar Ranjane @kalyan13 

I have figured out the error. 
Below is the code and snapshot 

 

 

 

(function executeRule(current, previous /*null when async*/ ) {
var caseTask = new GlideRecord("sn_customerservice_task"); //Gliding Case Task
caseTask.addQuery("parent", current.sys_id); //Checking if Case task has parent
caseTask.query();
while (caseTask.next()) { //if case task exist , updating work notes
var parent_case_state = current.getDisplayValue('state');
caseTask.work_notes = "Case state has been updated to" + " " + parent_case_state;
caseTask.update();
}

})(current, previous);

 

 



Gokul24_0-1674310024923.png


Thanks for the inputs

View solution in original post

11 REPLIES 11

kalyan13
Tera Guru

Hi @Dipali Pawar2 ,

Please try @Omkar Ranjane  solution, if you still unable to get the solution let me know 

Regards,

Kalyan 

Thank you @kalyan13 Omkar solution worked thanks for the help