Auto Close Lifecycle event case , once all child task gets close completed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 10:14 AM
Hi All,
I am trying to auto close lifecycle event case , when all the child tasks gets close completed . I have some activity sets which are triggering after 15 days . So Once all the tasks gets closed completed , I want to close the Parent case.
I have written BR on sn_hr_le_activity_set_context - this table and after update . and using below code. but its not working as expected , all the child tasks are going into error state. Kindly help me on my below issue.
if (current.workflow_context.id.hr_service.getDisplayValue() == 'Request Leave of Absence' && current.state == 'finished') {
var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('sys_id', current.workflow_context.id);
gr.query();
gs.info('Parul 30 ' + gr.getRowCount());
if (gr.next()) {
gr.state = 3;
gr.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 10:27 AM - edited 01-03-2024 10:28 AM
@ukti No need to write business rule for auto-closing the case. Simply check the Auto-close checkbox available on the HR Service form of Onboarding Service and choose Close when All to-dos are complete. This configuration will auto-close the case when all the to-dos related to lifecycle event case are completed.
For more information on this topic, please refer to https://docs.servicenow.com/bundle/vancouver-employee-service-management/page/product/human-resource...
Please mark this answer correct and helpful if it addresses your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 10:40 AM
Hi Sandeep,
As this will not work because it will not close the case immediately. There is a scheduled job , which will run after specific time and my requirement is to close immediately after all tasks closed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 07:59 PM
@ukti Ideally, you should stick to the out of the box to auto-close the cases. However, if you wish to stick to the business rule approach then I recommend setting the state of activity sets in the current activity set context (related to the current case)to finished first. This will allow the workflows attached with these activity set to complete then try setting the state of HR case to complete.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 05:20 PM
Hi Ukti,
what's the scheduled job name ?thanks