How to set the state field as closed completed once HR task all to dos completed

charitha ts
Tera Contributor

hello Team,

 

I have to close the state as closed completely in the sn_hr_core table, once all the HR tasks to DOS are completed on the HR task table.

I have created the BR as 

 

Table name - sn_hr_core_task table

Condition as Parent.Hr case.HR service -  HR service Request Leave of absence) 

State as Close to complete

Active changes to false

 

Condition :

 

 (function executeRule(current, previous /*null when async*/ ) { // check to see if any of our peers are currently *not* closed //
     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)) {
             grHRCase.state = current.state;
             grHRCase.work_notes = "Case closed as all to-dos are completed";
             grHRCase.update();
         }
     }
 })
 (current, previous);

 

After all HR task is closed also parent case state is in ready state only,

 

Thanks in advance

Charitha TS

 

 

 

 

2 REPLIES 2

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

@charitha ts This is a configuration for the HR Services when you have the fulfillment type of "Service Activity" or "Lifecycle Event". There is a scheduled job that runs and will close the case accordingly. In the image below I have outlined the source of this configuration.

michaelj_sherid_0-1702652479074.png

If my answer has helped with your question, please mark my answer as accepted solutions and give a thumb up.

Regards,

Mike

charitha ts
Tera Contributor

@michaelj_sherid  HR service is also updated on the same as you  mentioned