- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 02:09 AM
How to create a report of incident created from last month 20th to this month 20th. It should be dynamically updated in dashboard when month changes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 02:41 AM - edited ‎05-06-2025 02:49 AM
1 way is to use script in the report filter condition
1) create client callable classless script include and bring in the incidents created from 20th of last month and 20th of this month, return that array of sysIds
function getIncidents() {
// Get the current date
var currentDate = new GlideDateTime();
// Calculate the 20th of the current month
var currentMonth20th = new GlideDateTime();
currentMonth20th.setDayOfMonth(20);
// Calculate the 20th of the previous month
var previousMonth20th = new GlideDateTime();
previousMonth20th.addMonthsUTC(-1);
previousMonth20th.setDayOfMonth(20);
gs.info(previousMonth20th);
gs.info(currentMonth20th);
var arr = [];
// Create a GlideRecord query for incidents created between previousMonth20th and currentMonth20th
var gr = new GlideRecord('incident');
gr.addQuery('sys_created_on', '>=', previousMonth20th);
gr.addQuery('sys_created_on', '<', currentMonth20th);
gr.query();
// Process the results
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
return arr.toString();
}
2) then in report filter condition use this
sys id [IS ONE OF] javascript: getIncidents();
Note: I have tested the script, but please check and enhance, it gave me correct date as 20th April and 20th May
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 03:21 AM
Glad to help
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2025 05:15 AM
create classless script include as shared in my earlier screenshot
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader