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 ?

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
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

12 REPLIES 12

Hi,

This is just and example and is used for one record. If we use it wisely and with lookup records then only one flow will do your job and will not degrade the performance for sure.

This runs in background is not that complex.

Everything has its own advantage and downside, its upto us how to use it and not. 

Infact i have one subflow created in my environment to send reminder notifications for any table in servicenow. Assume how much time this saves. Only matter of passing values to that subflow and you are done.

But yes if its to complicated then we have to make sure it doesnot impact or haunt us later.

Thanks,
Ashutosh

@Ashutosh Munot 

 

Thanks for the idea, i definitely wanted to try with the flow designer let me follow your approach and will update you accordingly

He's already attached screenshot of the proposed Flow Design.

The flow is checking if it's the beginning of the quarter within the Action section. You'll still need to write Javascript code within the custom Action step.

So, it's not a matter of amount of Javascript code that needs to be written because both methods will require the same amount of code but where the code is written.

If the Flow Designer has a trigger for Quarterly event, I'll definitely recommend using the Flow Designer. As it is, there's more steps that has to be to done. This implies there's more things that needs to be maintained to use Flow Designer compared to using Scheduled Jobs.