How to Notify Someone 1 Week Before End Date

msekla
Tera Contributor

Is there a way to send out an email notification to the "Requested By" person on the External Vendor Access request for like a week before the end date is due?  Just notifying that the access will be rescinded soon, giving the person a chance to change/extend the due date, if needed. A screenshot of the form I am talking about is attached.

32 REPLIES 32

msekla
Tera Contributor

Please help @swathisarang98 

Hi @msekla ,

 

You can create a scheduled job and in that get the end date and before 7 days of end date you can trigger an event and once event is triggered based on that you can create a notification,

 

scheduled Job,

swathisarang98_0-1710355451496.png

 

 

var gr = new GlideRecord('sc_req_item');
gr.query();
if (gr.next()) {

    var startDate = new GlideDate();
    var gdt = new GlideDateTime(gr.variables.<fieldname>); // here add the backend name of  end date

    var dateDiff = GlideDateTime.subtract(startDate, gdt);
    var roundedDate = dateDiff.getRoundedDayPart();

    if (roundedDate == 6) {
        gs.eventQueue('expiry.notification', gr, '', '');
    } 

	// else if (roundedDate == 13) {
    //     gs.eventQueue('expiry.notification', gr, 14, '');
    // }


}

 

 

 

Event:

swathisarang98_1-1710355536814.png

Notification:

swathisarang98_2-1710355693308.png

swathisarang98_3-1710355716845.png

What it will contain you can add based on your requirement

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

 

 

 

 

Can't I configure the timer and notification in workflow? Wouldn't that be easier or would it not give the same result?

@msekla i have never tried it in workflow you can give it a shot, if it doesn't work you can go ahead with scheduled job and event 

 

Thanks 

Swathi