- 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 03:21 AM
you will have to do some custom logic for this if you don't see any such option in the date filter
create client callable script include and query and return those INCs which are created between the financial year you want
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 03:25 AM
I want create report on Incident table which are open for the financial year. Example: Current year June to Next year May.
I want this report to run every year. Can you suggest me the solution.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 03:27 AM
then create a report with this year June to next year May
then run a yearly scheduled job which runs on 31st May every year and simply update the report filter condition via GlideRecord
I shared solution few years ago, simply enhance it
Can we write script to change reports filter condition?
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:37 AM
Please help me to get Previous year June 1st in filter in below code.
var gr = new GlideRecord('sys_report');
gr.addQuery('sys_id','b44000f283290210a38da9e0deaad319');
gr.query();
if(gr.next())
{
var gdt = new GlideDateTime(gs.nowDateTime());
var query = "sys_created_onBETWEENjavascript:gs.dateGenerate('" + Previous year June 1st+ "','" + "00:00:00" + "')@javascript:gs.dateGenerate('" + gdt.getDate() + "','" + "00:00:00" + "')";
gr.filter = query;
gr.update();
}