- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 12:40 AM
I want to Write a script to close all resolved incidents which are not updated on last 3 days
I have hardcoded the last the days but i want it to be calculated.
var str ="state=6^sys_updated_on<=javascript:gs.dateGenerate('2022-08-09','23:59:59')";
var gr = new GlideRecord('incident');
gr.addEncodedQuery(str);
gr.query();
while(gr.next()){
gr.setValue('state','closed');
gs.print(gr.state);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 02:52 AM
Is your issue resolved?
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 12:44 AM
Hi
Use below encoded Query:
state=6^sys_updated_onRELATIVELT@dayofweek@ago@3
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 01:15 AM
Hi After updating the query :
//state=6^sys_updated_onRELATIVELT@dayofweek@ago@3
var str ="state=6^sys_updated_onRELATIVELT@dayofweek@ago@3"; //don’t use date ,calculate dynamically
var gr = new GlideRecord('incident');
gr.addEncodedQuery(str);
gr.query();
while(gr.next()){
gr.setValue('state','7'); //update the
gs.print(gr.state);
gr.update();
}
i am not getting any result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 02:23 AM
Are you sure, you have incidents last updated 3 days ago in resolved state?
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 02:52 AM
Is your issue resolved?
Feel free to mark correct, if your issue has been resolved, so it ends up in solved queue.
Will be helpful for others looking for the similar query.
Aman Kumar