How to create a reminder email before 5min

ying zeng
Tera Contributor

Hi, there

I have created a custom table and have fields named "resevdate" and "resevtime".
I want to automatically send a reminder email 5 minutes before the date and time selected by the customer.

What's the best way to send reminder notifications to user..

4 REPLIES 4

Devender Kumar
Tera Guru
Tera Guru

Hello @ying zeng 

 

I will suggest you to create a schedule Job for sending the reminder emails. You can fetch the values from "resevdate" and "resevtime" fields and write the script to calculate the time and trigger your notification through gs.event 

 

Here are some links you can refer 

https://www.servicenow.com/community/itsm-forum/send-an-email-15-minutes-prior-to-change-planned-sta...

 

https://www.servicenow.com/community/developer-forum/send-an-email-1-hour-prior-to-a-date-time-in-a-...

 

 

If my answer help you resolved your issue then mark it as solution accept or helpful.

 

Regards

Devender

yingzeng_0-1686559843062.png

I've created a System Scheduler but it doesn't work, can you check it for me pls?

 

Hi @ying zeng 

var gr = new GlideRecord('change_request');
gr.addQuery('first_field_date', gs.beginningOfToday()); 
gr.addQuery('hour_field', '08:00:00');
gr.query();
while(gr.next()) {
var gdt = new GlideDateTime(gr.getValue('first_field_date') +' '+gr.getValue('hour_field'));
gdt.addSeconds(-300);
var gdt1 = new GlideDateTime();
  if(gdt.equals(gdt1)) {
    gs.eventQueue("event_name", gr, "", "");
  }
}

 

Please first try to capture the first_field_date value and hour_field value in logs and check if it is giving the expected values or not. 

 

 

If my answer helps you to resolve your issue then hit correct or helpful.

 

Regards

Devender

Karthik Reddy T
Kilo Sage