How To Configure Auto close Incident Ticket (IM) and SD Ticket for specific time using Script


We have a sample script that will close the IM or SD ticket after a specific time:
1. Go to Script Library
2. Fill in the script info:
a. Name: IMClosure
b. Place the script in the script editor. Script is below.

3. Click ADD
4. Click on Compile (Modifications to the script requires it to be compiled again)
a. Should see “Successful compilation of JavaScript function or expression”
—————————————————————————————————
5. Create a Schedule Record (cmd line: sch):
a. Name: Auto Close IM
b. Class: problem
c. Scheduled Class: problem
d. Repeat Interval: 08/11/06 00:5:00 (runs every 5 minutes)
e. Application: script.execute.bg
download this RAD app from:
https://softwaresupport.hp.com/group/softwaresupport/search-result/-/facetsearch/document/KM443597

f. Status: scheduled
g.
h. In the JavaScript Tab, place this line in the editor:
i. system.library.IMClosure.IMClosure()

6. Click ADD to add the schedule.

Note:
The Auto Close script should run according to the schedule.
tolerancja=24; #meaning: the ticket will be close after 24 hours resolved.
oT = new Date();
oT.setMinutes(oT.getMinutes()-parseInt(tolerancja));

++++++++++++++++++++++++++++++++++++++++++++++
var Rel = new SCFile(‘screlation’);
var explanation = new Array();
tolerancja=24;
oT = new Date();
oT.setHours(oT.getHours()-parseInt(tolerancja));

CT = new XMLDate(oT);

var IncTable = new SCFile(“incidents”);
var query=”approval.status=\”resolved\” and category=\”request\” and interaction.status=\”Open\”” and resolved.time<‘”+ CT.getSCDateTimeString() +”‘ “;
var rc = IncTable.doSelect(query);
if (rc == RC_SUCCESS);
{
do
{
/*var d = new XMLDate( new Date() );
var js = d.getSCDateTimeString();*/
IncTable.resolution.push(“”);
IncTable.interaction_status=”Closed”;
IncTable.open=”Closed”;
IncTable.initial_impact=IncTable.initial_impact;
IncTable.resolution_code=”Automatically Closed”;
IncTable.resolution.push(“*** Auto-Closed by System ***”);
IncTable.doAction(“save”); // or IncTable.doSave();
}
while (IncTable.getNext()==RC_SUCCESS);
}

 

Hope you will find this helpful!!!

Have a nice day!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s