scheduled report on quarter basis

Community Alums
Not applicable

Hi,

I need to schedule a report on quarter basis. I set the run as monthly and in the conditional i used the below script but it was triggering every month. I see it report schedule for next month in schedule which it should not. Can anyone help how to resolve this issue.

 

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;

 

      }

 

5 REPLIES 5

Maik Skoddow
Tera Patron
Tera Patron

it's possible with one-liner

answer = new GlideDateTime().getMonth() % 4 === 0;

Community Alums
Not applicable

@Maik Skoddow 

Tried using above one liner and verified the schedules still it was showing wrong schedule

If you set the Schedule to "Monthly" (which is correct in your case) then of course you will see the next Schedule next month. However, at the moment when ServiceNow wants to run it, it will check the condition and abort if required (if "answer" is "false").

 

It cannot work in another way because new GlideDateTime() always returns the current date/time and this is only valid in the moment of execution. 

 

So everything works as expected!

Community Alums
Not applicable

@Maik Skoddow 

Thanks for the reply!

Is there a way to test the scheduled report is working as expected.