- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 03:14 AM
Hello All,
I have to create report incidents open in financial year. Kindly help me out how to create filter.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 09:15 PM
something like this, I hope this will help and you will be able to take it from here
var gr = new GlideRecord('sys_report');
gr.addQuery('sys_id','b44000f283290210a38da9e0deaad319');
gr.query();
if(gr.next())
{
var gdt = new GlideDateTime();
var currentYear = gdt.getYearLocalTime();
var nextYear = currentYear + 1;
var juneDate = currentYear + "-06-01"; // date is in YYYY-MM-dd format
var nextYearMayDate = nextYear + "-05-31"; // date is in YYYY-MM-dd format
var query = "sys_created_onBETWEENjavascript:gs.dateGenerate('" + juneDate + "','" + "00:00:00" + "')@javascript:gs.dateGenerate('" + nextYearMayDate + "','" + "00:00:00" + "')";
gr.filter = query;
gr.update();
}
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
04-17-2024 04:46 AM
in your scheduled job simply get the current year and next year date will always be static i.e. 1 June 2024 to 31 May 2025
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 04:54 AM - edited 04-17-2024 04:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 05:12 AM
why to run daily when the report condition will change only once i.e. in May
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 09:06 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct 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
04-17-2024 09:09 PM
Hello,
Good day.
I am still not getting logic and how can we handle year change in the script.
Could you please help me with script.
Thanks