Problem Closure and Related Incidents

tomcamish
Kilo Contributor

Hi All,

My business requirement specifies that incidents/problems are set to Resolved to await caller feedback, at which point the incident/problem is set to Closed if the caller selects close in the email they receive (the email bit isnt set up yet).

I currently have a script that, when a problem is set to "Resolved", the related incidents also get set to "Resolved". At this point our SLA pauses to await the caller feedback.

I need to add the following, but my Javascript knowledge is very limited:

  1. The Problem to automatically close once all of the related incidents are set to closed.
  2. The problem cannot be set to closed when there are related incidents that have not yet been closed.

The current code I have in place is below (I didnt create it):

if (current.state.changesTo(8)) {

    closeRelatedIncidents(current);

    closeRelatedTasks(current);

}

//

// Close any incidents that are related to the current problem

//

function closeRelatedIncidents(me) {

  var incident = new GlideRecord("incident");

  incident.addQuery("problem_id", "=", me.sys_id);

  incident.query();

  while (incident.next()) {

      if ( incident.state !== 'Closed' || incident.state !== 'Resolved' ){

          var msg = "Incident " + incident.number + ' resolved by problem '+me.number +' and will be closed based on caller response.';

          gs.print(msg);

          incident.state.setValue(8);

          incident.comments = msg;

          incident.update();

      }

  }

}

If there's anoyone who has done what I need to do, how did you do it?!

Thanks i advance.

10 REPLIES 10

Yep. You can do this using Business Rule or even in a UI actions for closure. The code I have given is for BR.


Is state value '8' above closed or resolved?


8 is "Resolved" and 9 is "Closed".


Tom - Please update the state values for Close as defined in your instance.


tomcamish
Kilo Contributor

My state values are already as I previously stated - 8 is "Resolved" and 9 is "Closed".