schedule a report per quarter

solymyr
Kilo Expert

Hello,

I am currently trying to schedule a report.

It is something that I have done quite a few times.

But today I am struggling to schedule the report at the beginning of every quarter.

The report should run at the beginning of every quarter.

Any suggestions on how to realize this?

1 ACCEPTED SOLUTION

Hi solymyr



YEs it is possible to run a report whenever you want it,


Open Scheduled Reports


Then select 'Monthly' under 'Run" field


Day :1


Conditional : true



Paste the script below under condition tab ;


      var gdt = new GlideDateTime(); // for example this month is january,


      gs.print(gdt.getMonth()); // output will be : *** Script: 1


      if (gdt.getMonth() == 1 || gdt.getMonth() == 5 || gdt.getMonth() == 9 ) {


                  answer = true;


      }



You want your scheduled report to operate every quarter, meaning on 1st january, 1st May, 1st September



Let me know if you need futher info.



Kind regards,



Do not feel shy to mark correct or helpful answer if it helps or is correct


View solution in original post

5 REPLIES 5

mike_bush
Kilo Guru

I think you schedule the report to run Monthly on Day 1 and then add a Condition to say "only if MONTH = JAN or APR or JUL or OCT" (for example)


Hi solymyr



YEs it is possible to run a report whenever you want it,


Open Scheduled Reports


Then select 'Monthly' under 'Run" field


Day :1


Conditional : true



Paste the script below under condition tab ;


      var gdt = new GlideDateTime(); // for example this month is january,


      gs.print(gdt.getMonth()); // output will be : *** Script: 1


      if (gdt.getMonth() == 1 || gdt.getMonth() == 5 || gdt.getMonth() == 9 ) {


                  answer = true;


      }



You want your scheduled report to operate every quarter, meaning on 1st january, 1st May, 1st September



Let me know if you need futher info.



Kind regards,



Do not feel shy to mark correct or helpful answer if it helps or is correct


Thanks for this,



Changed the script to use days by changing the method to getDayOfWeekUTC.



var gdt = new GlideDateTime();


gs.print(gdt.getDayOfWeekUTC()) // output for Monday will be: *** Script: 1


if (gdt.getDayOfWeekUTC() == 1 || gdt.getDayOfWeekUTC() == 2) {


        answer = true;


}



Tested for today and appears to work, should work for second condition tomorrow too.


zica
Giga Guru

I've made two typos,


The first one I edited in my previous post (it is : if (gdt.getMonth() == 1 || gdt.getMonth() == 5 || gdt.getMonth() == 9)) without the '||' after 9)


for the second one, if it does not work, try the condition like following :


          if (gdt.getMonth() == '1' || gdt.getMonth() == '5' || gdt.getMonth() == '9') {


                  ...


}



Really sorry for the typos



Kind regards,