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

 

To avoid coding you could download the scriptless scheduled jobs app from the link below:

https://community.servicenow.com/community?id=community_blog&sys_id=ae9caee1dbd0dbc01dcaf3231f96193d

 

ALternatively, you could configure an SLA to track the Next Email field, the SLA app already has a series of scheduled jobs that track fields and change the state of the SLA accordingly, you could use the state change of the SLA to trigger your notification.

Or, if you're on Kingston, you could try out the flow designer or try using a function field.

Mark263
Kilo Contributor

I'm unable to download the file. 

It's asking for a HI account and i don't have one.

Kindly help

 

Are you not able to register for an account?

Mark263
Kilo Contributor

Yes, I'm unable to create an account.

It's asking to contact Administrator.

find_real_file.png

Hello Mark

Look at this

I did created a sample table and add a field called "next_email".

I did register an event called "next_email"

 

I did created a scheduled job with this code:

// Get dateNowDT
var dateNowDT = new GlideDateTime();
gs.log('dateNowDT = ' + dateNowDT);

//Loop the incident table with the next_email field
//This is an example
var gr = new GlideRecord("u_glo_test"); //replace with incident table
gr.addEncodedQuery('u_next_emailISNOTEMPTY'); //replace with the filter criteria you want
gr.query();
while (gr.next()) {
	var nextEmail = gr.getValue('u_next_email');
	var nextEmailDT = new GlideDateTime(nextEmail);
	gs.log('nextEmail = ' + nextEmail);
	gs.log('nextEmailDT = ' + nextEmailDT);
	var result = dateNowDT.compareTo(nextEmailDT);
	gs.log('result = ' + result);
	
	if (result == 0) { //equals
		gs.eventQueue('next_email',current,'parm1','parm2');
	}
}

 

When the next_email date in the table is equals to nextEmailDT obatin in the scheduled job then an event in the queue is generated.

Look at this to the GlideDateTime comparisson examples

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideDateTime/concept/c_GlideDateTimeAPI.html

 

Next steps

You must create a notification when the event is fired

I think you must "mark" the record of the incident table with something similar to "processed"  or enhancement the query filter to prevent process the same rows twice or more.

 

I hope my answer has been useful

Ariel

PS: Please mark my answer correct or helpful if I have helped you. Thanks