last X days incidents
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 02:19 AM
how can i get last x days incidents in background scripts.
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 02:58 AM
ok fine nice , But how to get without encoded Query
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 09:02 AM
Hi, and without encoded Query.
var Xdays = 5; // update X
var inc = new GlideRecord("incident");
inc.query();
while (inc.next()){
var now = new GlideDateTime();
var incCreated = new GlideDateTime(inc.sys_created_on);
var timediff = GlideDateTime.subtract(incCreated, now);
var days = timediff.getRoundedDayPart();
if (days < Xdays) {
gs.print(inc.number);
}
}
Hope it helps