Automatic resumption of HR case from suspended to work in progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2023 05:11 AM
when HR case is suspended for a specific date and when the date is coming because of the scheduled job its coming work in progress at the time mentioned in the scheduled job. because of that we are loosing SLA based on country. Instead of scheduled job we have created one after query BR where it will calculate the time from the suspended date to fallow up date. But it is not working as expected. what would be the best practice to create this type of requirement.
(function executeRule(current, previous /*null when async*/) {
// Define HR case record to check for suspended state
var hrCase = new GlideRecord('sn_hr_core_case');
hrCase.addQuery('state', '24'); // Suspended state
hrCase.query();
while (hrCase.next()) {
// Get the suspend reason and extract the resume interval
var suspendReason = hrCase.getValue('u_follow_up_date');
var resumeInterval = suspendReason.match(/\d+/)[0]; // Assuming number of hours is a single integer
// Check if the resume interval has passed
var resumeTime = new GlideDateTime(hrCase.sys_updated_on.getGlideObject().getNumericValue() + resumeInterval * 60 * 60 * 1000); // Calculate the resume time based on the last update time and resume interval
if (resumeTime.before(new GlideDateTime())) {
// Resume the HR case by setting the state to 'In progress'
hrCase.setValue('state', '2' /*In progress*/);
hrCase.update();
}
}
})(current, previous);
Thanks,
Uday Kumar