- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 08:37 PM
Hello Team,
I'm trying to set auto close a request after 7 days. I have written business rule and schedule job but didn't worked can any one help me how to close the request.
Scheduled Job :
var gr = new GlideRecord('table name');
gr.addEncodedQuery(query);
gr.query();
gr.state = '5'; //set the state to closed
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 08:52 PM
I have the same
1. Create BR: When to run is after but without any condition
and the script. This request have the same time with incident. if you want to change it, just add your time in var ps = 7;
autoCloseRequest();
function autoCloseRequest() {
var ps = gs.getProperty('glide.ui.autoclose.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
if (pn > 0) {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('state', '5');
gr.addQuery('sys_updated_on', '<', queryTime);
gr.addQuery('u_coh', 'false');
while (gr.next()) {
gr.state = '3';
gr.comments = 'Request ditutup otomatis setelah ' + pn + ' hari dari tiket diselesaikan.';
gr.active = false;
gr.update();
}
}
}
And then create the scheduled job. fcScriptName=request autoclose, is the BR that create before. and it will run every 1 hour.
this is working fine in the instance. hope this will give you little help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 08:52 PM
I have the same
1. Create BR: When to run is after but without any condition
and the script. This request have the same time with incident. if you want to change it, just add your time in var ps = 7;
autoCloseRequest();
function autoCloseRequest() {
var ps = gs.getProperty('glide.ui.autoclose.time');
var pn = parseInt(ps);
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-pn);
if (pn > 0) {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('state', '5');
gr.addQuery('sys_updated_on', '<', queryTime);
gr.addQuery('u_coh', 'false');
while (gr.next()) {
gr.state = '3';
gr.comments = 'Request ditutup otomatis setelah ' + pn + ' hari dari tiket diselesaikan.';
gr.active = false;
gr.update();
}
}
}
And then create the scheduled job. fcScriptName=request autoclose, is the BR that create before. and it will run every 1 hour.
this is working fine in the instance. hope this will give you little help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 08:54 PM
Hello,
Write a Schedule job for this requirement which runs every day
var query = 'state=-4^sys_updated_onRELATIVELT@dayofweek@ago@7'; //state is resolved
var gr = new GlideRecord('table_name');
gr.addEncodedQuery(query);
gr.query();
while(gr.next()){
gr.state = '3'; //set the state to closed
gr.update();
}
Please Mark it helpful/Correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 09:03 PM
Hey Chaitanya,
In addition to above post refer the Link, it might help you:
Mark Correct and Helpful if you find my response worthy!!!
Best Regards,
Namrata.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2020 09:17 PM
I think the previous developer get the technic from this website. Its literally same. 😄