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

Hi Sree,

Thank u for ur reply.

your above mentioned code is working. However, it only works once.

If i change the date and time in the field,and save the form.The workflow doesnt execute for the second time.

Can i call this Workflow from a business rule? 

Kindly help

TIA

Archana Reddy2
Tera Guru

Hi Mark,

Write a before Business Rule with Inserted and Updated checked. Give it a try.

Create a notification which gets triggered by an event.


(function executeRule(current, previous /*null when async*/) {

gs.eventQueueScheduled('event_name',current,current.caller_id,'',current.u_next_email); //Your event name and field name.
    
 })(current, previous)

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

Thanks

Sagar Patro
Kilo Guru

You could use eventQueueScheduled.

Create after insert/update business rule...

Condition:

current.u_Next_Email.changes()

 

Script:

var date = new GlideDateTime(current.u_Next_Email.getDisplayValue());

gs.eventQueueScheduled("event_name" ,current, gs.getUserID(),gs.UserName(), date);

 

Now configure the notification for the event_name you specified above.

 

Mark this as correct and helpful if it was.

Hi,

Thank u for ur reply

Your code is working when the Next Email field is changed, However, i need to send the E-mail at the time selected in the field.

 

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.