Preview:

/* Complete all the Tasks and Child cases for the parent HR cases */

var parentCaseSysId = '<>';

// Close all the tasks
var grSnHrCoreTask = new GlideRecord('sn_hr_core_task');
grSnHrCoreTask.addEncodedQuery("parent=" + parentCaseSysId + "^state!=3^ORstate=NULL");
grSnHrCoreTask.query();

while (grSnHrCoreTask.next()) {
    grSnHrCoreTask.setValue('state', 3);
	grSnHrCoreCase.setWorkFlow(false);
    grSnHrCoreTask.update();
}



// Close all the child cases

var grSnHrCoreCase = new GlideRecord('sn_hr_core_case');
grSnHrCoreCase.addEncodedQuery("parent=" + parentCaseSysId + "^state!=3^ORstate=NULL");
grSnHrCoreCase.query();

while (grSnHrCoreCase.next()) {
	grSnHrCoreCase.setValue('state', 3);
	grSnHrCoreCase.setWorkFlow(false);
    grSnHrCoreCase.update();
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter