Send E-mail based on the Date/time selected in a field.

Mark263
Kilo Contributor

All,

I have a field on the incident form

Name : 'Next Email'

Type - Date/Time

An E-mail should be sent as per the date and time selected in that field.

Is this possible.? If yes, Kindly help

1 ACCEPTED SOLUTION

Mark,

eventQueueScheduled works to trigger an email on a particular date and time. Only when Next email is updated from empty to a new value, it triggers an event to be processed at the specified date and time.

https://docs.servicenow.com/bundle/jakarta-platform-administration/page/integrate/email-integrations...

I am not sure what is not working for you. 

View solution in original post

25 REPLIES 25

And, in the notification, you have to make the changes as below:

Fill the highlighted area with your event name.

--------------------------------------------------------------------

-----------------------------------------------------------------------------------

Mark the answer as Correct/Helpful based on its impact.

Thanks

Hi, 

I tried with the above code, it's not working.

E-mail are not triggered.

 

 

 

Mark,

This would work for this requirement.

var gr = new GlideRecord('incident');
gr.addQuery('u_next_email',new GlideDateTime());
gr.query();
while(gr.next())
{
gs.eventQueue('event_name',gr,gr.caller_id);
}

I have tested it and it is working. But this scheduled job needs to be run very frequently. Otherwise, the query cannot fetch the appropriate records since Next Email is a Date/Time field. So, Scheduled Job should run periodically(every second).

 

Mark the answer as Correct/Helpful based on its impact.

Thanks

It's not working for me.. 

 

Venkat799
Kilo Expert

Hello Mark,

Try a workflow which contains a timer and notification.

Make start condition as "next mail" field not empty.

Inside the timer write the script by selecting the script option.

answer = gs.dateDiff(gs.nowDateTime(),current.u_next_mail.getDisplayValue(),true);

now you can build notification however you like.

Regards

Sree