Auto close resolved incidents business rule and scheduled item is not working as expected

Roxi1
Tera Contributor

We have defined business rule, scheduled item, and system property to auto close the particular resolved incidents, but not closing the incidents and not getting any logs in system logs. can someone please help on it. here am pasting BR, schedueld item, and system property. for testing purpose we can not wait for days. is there any way that we can set some minutes.

after BR:

(function executeRule(current, previous /*null when async*/) {

// Add your code here
autoCloseIncidents();

function autoCloseIncidents() {
var ps = gs.getProperty('glide.ui.securityincidentautoclose.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
//queryTime.addSeconds(-pn);

if (pn > 0) {
var gr = new GlideRecord('incident');
gr.addEncodedQuery('category=IT Security^u_security_incident_stateNOT INproposed,accepted,rejected^incident_state=6');
// gr.addQuery('sys_updated_on', '<', queryTime);
gr.addQuery('sys_updated_on', '<', queryTime);
gr.query();
while(gr.next()) {
gr.state = 7;
gr.setLimit(3);
gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
gr.active = false;
gr.work_notes="Auto closed resolved incidents through Business rule";
gr.closed_by = gr.resolved_by;
gs.log("The resolved incidents are closed");
gr.update();
}
}
}
});

scheduled item:

find_real_file.png

System Property:

find_real_file.png

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I could see you have created similar questions in past which already have comments from members

Please avoid duplicate questions

Auto close business rule is not working with scheduled item

auto resolve closed incidents business is not working as expected

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Sorry for that, as i could not get correct help with that question, thought to create new one, can you please help here

I already shared the solution/approach on your older question.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

it seems no log is getting generated in system logs, means the BR itself is not triggering. can you please help me why this BR is not getting triggered