- 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 03:08 AM
Hi,
You can try in this way. Please check.
var gdt=new GlideDateTime();
gdt.addDaysUTC(-3);
var str ="state=6^sys_updated_on<=" + gdt;
var gr = new GlideRecord('incident');
gr.addEncodedQuery(str);
gr.query();
while(gr.next()){
gs.print("Test");
}