Report for financial year

Nikithesh R
Tera Contributor

Hello All,

 

I have to create report incidents open in financial year. Kindly help me out how to create filter.

 

Thanks.

1 ACCEPTED SOLUTION

@Nikithesh R 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

@Nikithesh R 

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Yes Please can you help me with script to run daily. 

Thanks

 

@Nikithesh R 

why to run daily when the report condition will change only once i.e. in May

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Nikithesh R 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

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