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:
download this RAD app from:

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

6. Click ADD to add the schedule.

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();

var Rel = new SCFile(‘screlation’);
var explanation = new Array();
oT = new Date();

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);
/*var d = new XMLDate( new Date() );
var js = d.getSCDateTimeString();*/
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!


Leave a Reply

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

You are commenting using your 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