The CreatorCon Call for Content is officially open! Get started here.

Child case closed once parent case is closed

abirakundu23
Mega Sage

Hi All/ @Mohith Devatte  / @Ankur Bawiskar ,

Once parent case is closed complete child case also be complete.
Parent case is (sn_hr_core_case_global_mobility) and child 2 cases are the table (sn_hr_core_benefits).

both tables have parent and child relation ship. Once we complete parent case the child case is closed complete.
but in our cases child cases are cancelled. why it  is happening ??

that's why i tried BR once parent case closed complete child case should be complete. Any error these BR ??
before update. it is not working.

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

    // Add your code here
    var closedChild = 0;
    var grCase = new GlideRecord('sn_hr_core_case_global_mobility');
    grCase.addQuery('parent_sn_hr_core_case_global_mobility', current.sys_id);
    grCase.query();
    var totalChildCount = grCase.getRowCount();
    gs.addInfoMessage("CNT: " + totalChildCount);

    while (grCase.next()) {
        if (grCase.state == 18) {
            closedChild += 1;
        }
    }
    if (closedChild != totalChildCount) {
        gs.addErrorMessage("please close All child cases");
        current.setAbortAction(true);
    }

})(current, previous);




 

 

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Did you check any other BR is setting the state as cancelled?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader