Marco Nappo_
Mega Guru
ServiceNow has an option to automatically close an HR Case once all the HR Tasks are completed for HR Service Activities. Unfortunately this is not always working as needed because it’s a scheduled job that runs periodically so you might need to wait many hours before this case it’s actually closed. The suggestion is to create a new case option called “Automatically Close Instantly” for all the HR Services you wish to close instantly once the HR Tasks are all completed. This can be useful in general but this is useful especially when the agent is fulfilling many tasks and only one of them is to ask the employee to sign a document in a child case. I have already created an HR Service for Employment Verification Letter if you wish to know more about that please see the other videos of the series (https://community.servicenow.com/community?id=community_video&sys_id=4244ee9edba7a010679499ead39619b8) Business Rules on HR Task []sn_hr_core_task] When to run: after update Filter Conditions: Active changes to false Parent.HR Case.HR Service.Case options contains Automatically close Instantly Advanced: (function executeRule(current, previous /*null when async*/ ) { // check to see if any of our peers are currently *not* closed // current=HR Task var grSiblingsHRTask = new GlideRecord('sn_hr_core_task'); grSiblingsHRTask.addQuery('parent', current.parent); grSiblingsHRTask.addActiveQuery(); grSiblingsHRTask.query(); if (!grSiblingsHRTask.next()) { // If NOT Siblings open var grHRCase = new GlideRecord('sn_hr_core_case'); if (grHRCase.get(current.parent)) { // Find parent case of HR Task var hrCaseNumber = grHRCase.number; var hrCaseService = grHRCase.hr_service; grHRCase.state = current.state; grHRCase.work_notes = "Case closed as all to-dos are completed"; grHRCase.update(); if (grHRCase.get(grHRTask.parent.parent)) { grHRCase.work_notes = "Child case:"+hrCaseNumber+"-"+hrCaseService+" has been closed as all his to-dos are completed"; grHRCase.update(); } } } })(current, previous);
4 Comments