How do I create a one month or 1 week reminder to trigger the email notification?

ChuanYanF
Tera Guru

Dear experts,

 

I am currently stuck in the condition field where I want the system to fetch the date one month before the field value under the sn_risk_risk form u_risk_due_date field value, where it will trigger the email to be send one month before the value? How should I build my condition query in the scheduled jobs? And if so how do I configure for 2 weeks and 1 week reminder as well?
This is my current script:

var gr = new GlideRecord('sn_risk_risk');
if (gr.get(current.sys_id)) {
    var currentDate = new GlideDate(); // today's date
    var dueDate = new GlideDate(gr.u_risk_due_date); // the record's due date

    // Subtract one month from due date
    dueDate.addMonths(-1);

    // Compare with today
    if (dueDate.compareTo(currentDate) == 0) {
        answer = true;
    } else {
        answer = false;
    }
} else {
    answer = false;
}
3 REPLIES 3

Mark Manders
Mega Patron

Why use complex scripting in a scheduled job? If you use a scheduled flow, you can just lookup the date/time and wait until one month before it. The calculation will be done in the action.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,

 

Can you explain more detail in how the scheduled flow can be done? Thanks for your reply

You create a flow and trigger it on your schedule (like daily).
You do a look up to all records that are at one month from now and with a 'for each' you use the 'send notification' action to trigger the notification.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark