Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Scheduled Job: Auto-Close Resolved HR Cases

mdshahvez11
Tera Contributor
 

Hello @Everyone,

This scheduled job is designed to automatically close HR cases. It works by using an encoded query: when a case is in the Resolved state and has not been updated for more than 7 days, the job updates its state to Closed.

However, I recently noticed that the job is not functioning as expected. The logs show “Total cases closed: 0”, but no cases are actually being closed.

I suspect that the encoded query may not be returning the correct set of records that need to be closed. Further investigation is required to ensure the query logic correctly identifies eligible cases.

**Script Below**

(function autoCloseResolvedCases() {
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('sys_updated_onRELATIVELE@dayofweek@ago@7^state=8');
gr.query();

var count = 0;

while (gr.next()) {
gr.state = 3; // Closed
gr.update();
gs.info('Auto Closed Record: ' + gr.number + ' | Last updated on: ' + gr.sys_updated_on);
count++;
}

gs.info('Auto Closed Records Total Count: ' + count);
})();

 
 

 

0 REPLIES 0