When closing parent Case auto close case tasks

Vic4
Tera Contributor

Hi I am looking for some guidance on how to automatically close case tasks once parent case is closed.

2 ACCEPTED SOLUTIONS

Pavankumar_1
Mega Patron

Hi @Vic4 ,

1.Create the After Business rule on case(sn_customerservice_case) table and when to run tab check update and give condition as state changes to closed. And use below script.

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

    var cstsk = new GlideRecord('sn_customerservice_task');
    cstsk.addQuery('parent', current.sys_id); //filter the current case record
    cstsk.query();
    while (cstsk.next()) {
        cstsk.state = '3'; //add task close state value
        cstsk.update();
    }

})(current, previous);

2. Refer below Business rule screenshots:

Screenshot (554).png

Screenshot (555).png

 

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

Community Alums
Not applicable

Hi @Vic4 ,

There is not currently anything in the platform shipped Out of Box (OOB) as of Rome within Case which has this same idea/functionality.

 if needed this sort of functionality in yourr instance, you could simply review the Service Catalog "Close Parent if Required" Business Rule and modify it for the Case table according to their business needs. That way, whenever all Case Tasks (CSTASK) on a Case were closed, the parent case would close also.

 

View solution in original post

2 REPLIES 2

Pavankumar_1
Mega Patron

Hi @Vic4 ,

1.Create the After Business rule on case(sn_customerservice_case) table and when to run tab check update and give condition as state changes to closed. And use below script.

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

    var cstsk = new GlideRecord('sn_customerservice_task');
    cstsk.addQuery('parent', current.sys_id); //filter the current case record
    cstsk.query();
    while (cstsk.next()) {
        cstsk.state = '3'; //add task close state value
        cstsk.update();
    }

})(current, previous);

2. Refer below Business rule screenshots:

Screenshot (554).png

Screenshot (555).png

 

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Community Alums
Not applicable

Hi @Vic4 ,

There is not currently anything in the platform shipped Out of Box (OOB) as of Rome within Case which has this same idea/functionality.

 if needed this sort of functionality in yourr instance, you could simply review the Service Catalog "Close Parent if Required" Business Rule and modify it for the Case table according to their business needs. That way, whenever all Case Tasks (CSTASK) on a Case were closed, the parent case would close also.