Incident and proper closing of the underlying task fields
Since launch, we have had issues where the task table behaves inconsistently with the various modules: Incident, SCTASK, RITM, Problem.
D676 was a fix so that moving forwards, Incident module will properly close both the Incident ticket fields and the underlying Task fields, such as Task State, etc.
We also have an issue of how to properly fix the existing data, working backwards. This is a script that will walk through the existing Incident table and fix things up:
var incident_count = 0; var incident = new GlideRecord('incident'); incident.addEncodedQuery('incident_state=6^ORincident_state=7'); incident.query(); while (incident.next()) { incident_count ++; gs.log("Incident: " + incident.number + " has Incident State: " + incident.incident_state + " and State: " +incident.state + " will be changed."); if (incident.incident_state == 6) { incident.state = 6; } if (incident.incident_state == 7) { incident.state = 3; } incident.autoSysFields(false); incident.setForceUpdate(true); incident.setWorkflow(false); incident.update(); } gs.log("Incidents modified: " + incident_count);