
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2015 08:50 AM
So for some odd reason the "autoclose incident" business rule stopped entering the close date even though it is changing the state to close.
So now I have over 700 tickets that are no longer active and state is closed but is missing a closed date.
If I can just populate the update date to the closed date field then we can run our reports properly. Without a closed date I am having problems with reporting.
Here is what I have so far but it didn't work. Any assistance would be appreciated.
var inc = new GlideRecord('incident');
inc.addQuery('active','false');
inc.addQuery('state','7');
inc.addQuery('closed_at','null');
inc.query();
var count = 0;
while(inc.next()){
count++;
inc.sys_updated_on = inc.closed_at;
inc.update();
}
gs.print(count);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2015 08:59 AM
Hi Pam,
Try this.
var inc = new GlideRecord('incident');
inc.addQuery('active','false');
inc.addQuery('state','7');
inc.addQuery('closed_at','null');
inc.query();
var count = 0;
while(inc.next()){
count++;
iinc.closed_at=nc.sys_updated_on ;
inc.update();
}
gs.print(count);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2015 08:59 AM
Hi Pam,
Try this.
var inc = new GlideRecord('incident');
inc.addQuery('active','false');
inc.addQuery('state','7');
inc.addQuery('closed_at','null');
inc.query();
var count = 0;
while(inc.next()){
count++;
iinc.closed_at=nc.sys_updated_on ;
inc.update();
}
gs.print(count);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2015 10:24 AM
I see what I did wrong. Thanks for the assist.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2015 09:03 AM
On sysauto_script.list create new
var gr = new GlideRecord('incident');
gr.addEncodedQuery('closed_atISEMPTY');
gr.addEncodedQuery('active=false');
gr.query();
while(gr.next()){
gr.closed_at = gr.sys_updated_on;
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2015 10:28 AM
Thanks for all the assist. Here is the final code that I used.
var gr = new GlideRecord('incident');
gr.addQuery('active', false);
gr.addQuery('state', 7);
gr.addQuery('closed_at', '');
gr.query();
while (gr.next()) {
gr.closed_at = gr.sys_updated_on;
gs.print('ticket modified: ' + gr.number + ', updated date: ' + gr.sys_updated_on + ', close date: ' +
gr.closed_at);
gr.setWorkflow(false);
gr.update();
}