Auto Close Lifecycle event case , once all child task gets close completed

ukti
Tera Contributor

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();
        }
    }

ukti_0-1704305655213.png

 

 

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@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.

 

Screenshot 2024-01-03 at 11.52.41 PM.png

Screenshot 2024-01-03 at 11.56.30 PM.png

 

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.

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.

@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.

sara14
Tera Contributor

Hi Ukti,

what's the scheduled job name ?thanks