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 , it will be available in RITM Variables it would look something like below,

 

swathisarang98_0-1710856300995.png

 

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

Regards,

Swathi Sarang

 

@swathisarang98 Here are all of the screenshots you asked for.

Hi @msekla ,

 

I have updated the schedule job to your requirement , it working correctly like including today it will check for next 6 days which is 7 days and will trigger notification,

 

and the addEncodedQuery will check only for your catalog item and it will check state is not closed (if required update the query )

 

 

var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('cat_item=90527e0393ecc6504487bd6cebba1078^stateNOT IN3,4,7'); // here add your catalog item name
gr.query();
while(gr.next()) { // change if to while

    var startDate = new GlideDate();
	var endDate = gr.variables.end_date;
    var gdt = new GlideDateTime(endDate);
	//gs.info('Line number 6 ' + gdt);
    
    var dateDiff = GlideDateTime.subtract(startDate, gdt);
    var roundedDate = dateDiff.getRoundedDayPart();

	
	//gs.info(' line number 12 ' + roundedDate);

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

 

 

 

and in your notification please add the "Requested for" for who will receive, which is missing 

 

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

Regards,

Swathi Sarang

@swathisarang98 Where would I add the requested for? And what's my catalog item name, do you mean the name of the form itself in the catalog which is External Vendor Access Request? Also, please remove any logging in the code like gs.info.

@msekla , in notification please add below,

swathisarang98_0-1710862135892.png

 

yes the form sys_id you have to add otherwise it will run for all the ritm,

 

what you can do is go to sc_req_item.LIST in the filter add the below ,

swathisarang98_1-1710862315475.png

 

on the bread crumbs right click and copy query ,

swathisarang98_2-1710862459064.png

 

and paste it in gr.addEncodedQuery('here');

 

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

Regards,

Swathi Sarang