How do I send email notification 14 days before variable end date for a catalog item?

mzmoore
Mega Expert

I have a need to send an email reminder notification to users 14 days before the variable end_date for a service catalog item.

If the end date is 4/11, I need an email reminder to send on 3/28. How would I accomplish this? 

Thank you.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can also use flow designer with no script

check this

Approval Reminder for Approval Records using flow designer

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use this approach

1) Event and notification on sc_req_item table

2) daily scheduled job

Script as this

1) give your catalog item name

2) give your date variable name

3) give your event name

sendReminder();

function sendReminder() {
	var task = new GlideRecord('sc_req_item');
	task.addQuery('active','true');
	task.addQuery('cat_item.name', 'Your item Name');
	var encodedQuery = task.variables.dateVariable + 'RELATIVEGE@dayofweek@ahead@14^' + task.variables.dateVariable + 'RELATIVELE@dayofweek@ahead@15';
	task.addEncodedQuery(encodedQuery);
	task.query();
	while(task.next()){
		gs.eventQueue('event_name', task, 'recipients');
	}
}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello and Thank you. Is this where I would create the Event? find_real_file.png

Hi,

I believe you are pretty new in ServiceNow. I would suggest to refer few of the basic courses.

Please refer docs for help

ServiceNow Email Notification via Event

Events

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am having the same requirement but it a record producer and expiry date is the variable of record producer.

i tried the below code but it is not working

 

find_real_file.png