The CreatorCon Call for Content is officially open! Get started here.

to send notification

abhi159
Kilo Sage

i have a table in which i have date field now i want to send notification before 30 days of the selected date 

1 REPLY 1

Anand Kumar P
Giga Patron

Hi @abhi159,

Create a schedule job that runs on daily and trigger notification from schedule job and add event in notification and schedule job.

Script:

var today = new GlideDateTime();
today.setDisplayValue(new GlideDate());

var notificationDate = new GlideDateTime(today);
notificationDate.addDays(30);

var myTable = new GlideRecord('your_customtable_name');
myTable.addQuery('date_field', '>', today);
myTable.addQuery('date_field', '<=', notificationDate);
myTable.query();

while (myTable.next()) {
gs.eventQueue(ā€˜eventname’,current,parm1,parm2);
}

https://www.servicenow.com/community/developer-forum/creating-schedule-job-to-send-notification/m-p/... 

Please mark it as solution proposed and helpful if its serves your purpose.

Thanks,

Anand