@JohnnySnow 

in your script why not query HR Task table instead of HR case?

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