how to send notification at a particular date and time in servicenow

damarlaravi
Kilo Contributor

we have one field next review date, my requirement is send a notification 1 day prior to that next review date.

I wrote the following code to send notification but notification is triggering on current date and time only

function onAfter(current, previous) {

    //This function will be automatically called when this rule is processed.

    var date1 = new GlideDateTime();

  var review_date=current.u_next_review_date;

      date1.setDisplayValueInternal(review_date);

  date1.addDays(-1);

gs.eventQueueScheduled("incident.reminder", current, gs.getUserID(), gs.getUserName(), date1.getDisplayValue());

}

Guys can u please help on this, any suggestion is helpful

6 REPLIES 6

amacqueen
Mega Guru

Not sure if this helps but we have something similar so I thought I would share.



We have an after BR on the incident table on Insert and Update with the condition current.u_reminder.changes() and the following script:-



gs.eventQueueScheduled("incident.reminder", current, gs.getUserID(),


gs.getUserName(), current.u_reminder);



I didn't write it an I'm not much of a coder, so good luck


Mail is triggering as of there in field   'u_reminder' but my requirement is to send at one day before. If i modify the date in 'u_reminder' according to previous day then mail is not triggering at that date and time but it mail is triggering at current point of time


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

when i was adding some customizations like


var review_date=current.u_next_review_date;


      date1.setDisplayValueInternal(review_date);


  date1.addDays(-1);



on that date field eventQueueScheduled() method   is not working