java.lang.NullPointerException : nulljava.lang.NullPointerException : null

Eileen Hessmill
Mega Expert

Our Auto Close Incidents scheduled job is sometimes receiving this error: java.lang.NullPointerException : null, which from what I read is caused by a blank variable.

I think it is why many of our Resolved incidents remain active after the # of days in the property for the auto close.

The job runs the incident autoclose business rule.

autoCloseIncidents();

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

if (pn > 0) {
  var gr = new GlideRecord('incident');
  gr.addQuery('incident_state', IncidentState.RESOLVED);
  gr.addQuery('sys_updated_on', '<', queryTime);
  gr.query();
  while(gr.next()) {
    gr.incident_state = IncidentState.CLOSED;
    //   gr.comments = 'Incident automatically closed after ' + pn + ' days in the Resolved state.';
    gr.active = false;
    gr.closed_by = gr.resolved_by;
    gr.update();
  }
}
}

I checked the value of all the fields for an incident that remains Resolved long after the glide.ui.autoclose.time period, and didn't find anything that was blank.

Is this the right direction to trouble shoot the issue?

Thanks!

2 REPLIES 2

Rajesh Mushke
Mega Sage
Mega Sage

Please refer below KB article might be helpful



ServiceNow KB: Lookup select variable does not render in Wizards on second load (KB0549373)




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Gaurav Bajaj
Kilo Sage

Hi,



Please add the code in try catch block to have better hold on the error logs received. This might provide a better view of the issue.




Thanks


Gaurav