How should I set the run schedule if I want to trigger an email to be sent by 1st of June yearly?

ChuanYanF
Tera Guru

Dear experts,

 

I have created a scheduled job to trigger the email to be sent out on 1st of June yearly, if I want to make it as to run yearly since it does not have the option. How should I make sure it will trigger on the first of June every year. What I am doing now is periodically with 365 days, but not sure this is the correct approach on this. Please advise.

ChuanYanF_0-1748919002679.png

 

2 ACCEPTED SOLUTIONS

Chaitanya ILCR
Kilo Patron

Hi @ChuanYanF ,

ChaitanyaILCR_0-1748923190703.png

if (new GlideDate().getMonth() == 7) {
    //write your logic here
}

 

you can use this 

the problem with 365 days is leap year contains 366 days and it won't trigger extactly on july 1st with on a leap year and followup years

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@ChuanYanF 

you can make it run Monthly on 1st Date

Then use this in the condition field so that it only runs on 1st June and not on any other date

this will handle leap year etc

AnkurBawiskar_0-1748924975640.png

 

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

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @ChuanYanF ,

ChaitanyaILCR_0-1748923190703.png

if (new GlideDate().getMonth() == 7) {
    //write your logic here
}

 

you can use this 

the problem with 365 days is leap year contains 366 days and it won't trigger extactly on july 1st with on a leap year and followup years

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Ankur Bawiskar
Tera Patron
Tera Patron

@ChuanYanF 

you can make it run Monthly on 1st Date

Then use this in the condition field so that it only runs on 1st June and not on any other date

this will handle leap year etc

AnkurBawiskar_0-1748924975640.png

 

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

maheshkhatal
Mega Sage

Hello @ChuanYanF ,

        You can use/explore GlideDateTime api. You can follow the steps given below:

      var gdt= new GlideDateTime();

     var currentMonth = gdt.getMonthUTC();//Similarly you can take year,weekend etc.

//Make sure currentMonth is either string or integer and then compare in the if loop

//to check the type you can log gs.log('Current month type:'+typeof currentMonth);

   if(currentMonth ==7){

     //You logic part whatever you want to implement you can do here.

}

Please mark my response as helpful if it resolved your doubt.

Thank you,

Mahesh.