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

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Why not use flow designer instead of scheduled job.


Thanks,
Ashutosh

I tried it with Flow Designer and found there's not quarterly nor was able to enter a script in the trigger condition.

Hi,

We can put first step in that flow as a script step which checks the current date as quarter.

Will get back to you with that flow.


Thanks,
Ashutosh

Hi,

This is the Flow and action:

find_real_file.png

This is for sending reminder if due date is in last quarter. Check if last quarter is my custom action which can be reutilised everywhere in other flows.

find_real_file.png

 

This is the action code and input outputs. Output is boolean true or false.

 

Testing:

find_real_file.png

Why i am saying flow designer because no need of event and extra notification. Everything in one place and easy to maintain.

 

Thanks,
Ashutosh Munot

You'll also be assuming that the quarter will start on Monday. That can be changed to Daily but it doing everything like this is going to have a performance degrade on the instance if there's too many.

I do love Flow Designer but putting too much is going to have performance hits especially if it's in the Global Scope.

The logic in Flow Designer actually get more complicated than scripting and I'm feeling that it'll get more difficult to maintain.

I'll write high level business flows in Flow Designer while sticking with scripting in low level processes.

Well, just my thought.