SM 9.X : How to Auto close the Resolved Incident tickets created from OMi Event

  • KM03144575
  • 17-Apr-2018
  • 17-Apr-2018

Summary

This document will provide a java script that can be used to auto close the incident tickets in Resolved state created from OMi Events, The script can further be scheduled to execute once in 24 hours or 48 hours based on requirement.

Question

This document will provide a java script that can be used to auto close the incident tickets in Resolved state created from OMi Events, The script can further be scheduled to execute once in 24 hours or 48 hours based on requirement.

Answer

The below java script will close the Incident tickets which are in resolved state for more than 48 hours and which has created from OMi event.

 

function inc_autoClose()

{

clsHours = 48;//I have set time as 48 hours. You can change it as per your requirement;

 

fndTime = new Date(); fndTime.setHours(fndTime.getHours()-parseInt(clsHours));

NT = new XMLDate(fndTime);

var srchIncidents = new SCFile( "probsummary" );

 

var sqlQuery = "problem.status=\"Resolved\"" && "opened.by=\"falconomi\""; // use the integration user name in this example, i have used it as "falconomi"

 

if (srchIncidents.doSelect( sqlQuery ) == RC_SUCCESS) { do { srchIncidents.flag = false; srchIncidents.problem_status = "Closed"; if (srchIncidents.resolution_code == null) { srchIncidents.resolution_code = "Automatically Closed"; } srchIncidents.doAction("close"); } while ( srchIncidents.getNext() == RC_SUCCESS ); } }

inc_autoClose();

 

The above java script can be called through a scheduler.

 

STEPS

 

1. Logon SM eclipse client using falcon.

2. Command: sch

3. Input these values:

Name: Give any name here

Class: problem

Expiration Time: set to current time

Scheduled Class: problem

Action Time: set to current time

Description tab:

Repeat Internal: Other -> 00:01:00 (This means to execute this schedule record every 1 min. so it will run every 1 min. you can set the time as per your requirement for the scheduler to run )

Java Script tab: copy paste the script

 

function inc_autoClose()

{

clsHours = 48;//I have set time as 48 hours. You can change it as per your requirement;

 

fndTime = new Date(); fndTime.setHours(fndTime.getHours()-parseInt(clsHours));

NT = new XMLDate(fndTime);

var srchIncidents = new SCFile( "probsummary" );

 

var sqlQuery = "problem.status=\"Resolved\"" && "opened.by=\"falconomi\""; // use the integration user name in this example, i have used it as "falconomi"

if (srchIncidents.doSelect( sqlQuery ) == RC_SUCCESS) { do { srchIncidents.flag = false; srchIncidents.problem_status = "Closed"; if (srchIncidents.resolution_code == null) { srchIncidents.resolution_code = "Automatically Closed"; } srchIncidents.doAction("close"); } while ( srchIncidents.getNext() == RC_SUCCESS ); } }

inc_autoClose();

P.S: Please test the script in the script library on your development system before production