last six month incident record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:38 AM
how to get the last six month incident record without encoded query??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:43 AM
var incidentGR = new GlideRecord('incident');
var sixMonthsAgo = new GlideDateTime();
sixMonthsAgo.subtract(6 * 30 * 24 * 60 * 60);
incidentGR.addQuery('sys_created_on', '>=', sixMonthsAgo);
incidentGR.query();
// Loop through the result set and do something with each incident record
while (incidentGR.next()) {
// You can access incident fields using dot notation
var incidentNumber = incidentGR.getValue('number');
var shortDescription = incidentGR.getValue('short_description');
// Do whatever you need to do with the incident data
gs.info("Incident Number: " + incidentNumber + ", Short Description: " + shortDescription);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:44 AM - edited ‎07-26-2023 05:44 AM
Hi @shid077 ,
Use,
var gr = new GlideRecord('incident');
gr.addQuery('sys_created_on', '>=' , 'javascript:gs.daysAgo(180)');
gr.query();
while(gr.next()){
gs.print(gr.number);
}
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 06:04 AM
Hello @shid077
Please refer following code,