Need help on trigger notification quarterly

shaik_irfan
Tera Guru

Hi,

I have a requirement where i need to send a notification as a reminder on last week of every quarter. 

 

Example:

March 23 of 2020 for Q1

June 22 of 2020 for Q2 and so on.

 

Can anyone please help me out how to acheive this ?

Hitoshi Ozawa
Giga Sage

Answer by Aman Reddy Gurram  in the following thread offers an answer. He's creating a "System Definition" -> "Scheduled Jobs" and checking "Conditional". 

https://community.servicenow.com/community?id=community_question&sys_id=df1363afdbdf6f40107d5583ca96...

Jaspal Singh
Mega Patron

Hi Irfan,

 

You can create a schedule job that Runs as below with script.

find_real_file.png

executeonLastWeek();

function executeonLastWeek() {
    //gives you current date time
    var getdtime = new GlideDateTime();
	
	//gives you current month number 1-Jan, 2-Feb, so-on
    var getmonth = getdtime.getMonth();
	
	//execute only if it is start of quarter
    if (getmonth == '3' || getmonth == '6' || getmonth == '9' || getmonth == '12') {
		
		//gets you number of days in month 30 or 31 or 29
        var days_in_month = getdtime.getDaysInMonthUTC();
		
		//gets you today's date
        var day_of_month = getdtime.getDayOfMonthUTC();
		
        if (day_of_month >= days_in_month - 6) {
            //return true;
            //your script here to set reminder gs.eventQueue();
        } else {
            //	return false;
            //do nothing
        }
    }
}

View solution in original post

It's probably better to check on "Conditional" and write the execution time login in the "Condition" script rather than write it in "Run the Script" area.

That is just an example & suggestion. Can be tailored in a way that fits best as per your need.