- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2019 02:40 AM
I have a record producer that creates a HR Case. This HR case has an associated HR Service which has two tasks tagged on to it. I would like to set it in a way where when the last task is completed the Hr case is automatically set to closed (or awaiting acceptance).
Is this possible?
I don´t mind any type of solution but i thought this was something that could be done OOTB with New York.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2019 10:32 AM
Hi,
I believe we can do it in few ways:
1) Async Business rule on task table.
2) Editing and managing workflow.(Bit tricky and might not be good)
3) Use gs.sleep in business rule so that it will run ur code bit late i.e after 3 4 secs.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2019 10:32 AM
Hi,
I believe we can do it in few ways:
1) Async Business rule on task table.
2) Editing and managing workflow.(Bit tricky and might not be good)
3) Use gs.sleep in business rule so that it will run ur code bit late i.e after 3 4 secs.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 05:39 AM
I used the async as the BR type and and it sorted the problem. Thank you very much for your help!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2025 09:47 PM - edited 05-22-2025 09:47 PM
Below Business rule can be implemented for this requirement
Condition: Aysnc Update
Filter Could Be: HR service which you have created for Lifecycle Event and state changes to Close Complete
Table: sn_hr_core_task
You need to check the activity set context if the trigger condition is different for the activity sets otherwise it will close the case without checking the activity set status.
This Business rule will check that all mandatory task is completed then it will close the case. You can modify the query as needed, also gs.sleep() will not work in scoped application, hence custom script is written to wait for 5 sec so that context can be updated.
(function executeRule(current, previous /*null when async*/ ) {
//current = HR Task
var grSiblingsHRTask = new GlideRecord('sn_hr_core_task');
grSiblingsHRTask.addQuery('parent', current.parent);
grSiblingsHRTask.addQuery('optional', false);
grSiblingsHRTask.addActiveQuery();
grSiblingsHRTask.query();
var endSleep = new GlideDuration().getNumericValue() + 5000;
while (new GlideDuration().getNumericValue() < endSleep) {
//wait for 5 sec
}
var activitystatus = new GlideRecord('sn_hr_le_activity_set_context');
activitystatus.addQuery('hr_case', current.parent);
activitystatus.addEncodedQuery('stateINawaiting_trigger,running_activities,faulted');
activitystatus.query();
if (!grSiblingsHRTask.next() && !activitystatus.next()) {
var grHRCase = new GlideRecord('sn_hr_core_case');
if (grHRCase.get(current.parent)) {
grHRCase.state = 3;
grHRCase.work_notes = "Case closed as all mandatory tasks are completed";
grHRCase.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2019 10:53 AM
Hi,
you can do this using workflow, without any coding required.
Create the tasks in the workflow and once the 2nd task is closed, mark the hr_case closed.
Mark the comment as a correct answer and hepful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2021 10:34 AM
Thank you for this response