Send an email exactly 15mins before the due_date of a task

SandaminiM
Tera Contributor

Hi Community 😊

I want to send an email to the Assignee (assigned_to) 15mins prior to the Due Date (due_date) of a task, if the task's state is 'Scheduled'. Can I achieve this using flow designer or else how can I achieve this ?? Please help.

Thanks in advance !!!

4 ACCEPTED SOLUTIONS

Anwesha3
Mega Guru

It will require scripting ,
something like this - 
var gdt = new GlideDateTime(<due date field name>); 
gdt.addSeconds(-900);

gs.eventQueueScheduled("<name of event queue > ", current, "", "",gdt);

Kindly mark the reply as a correct answer / helpful if it helped to solve your question.

Thanks,
Anwesha

View solution in original post

Rohini S Sane
Tera Guru

@SandaminiM ,

You can write schedule job with below code.

 

 

 

var gr = new GlideRecord('task');
gr.addQuery('state', 'scheduled'); 
gr.query();
while(gr.next()) {
var gdt = new GlideDateTime(gr.due_date); //put actual field name
gdt.addSeconds(-900);
gs.eventQueueScheduled("task.remainder", gr, "", "",gdt);
}

 

 

View solution in original post

Voona Rohila
Kilo Patron
Kilo Patron

Hi @SandaminiM 

There are few ways you can achieve this

1. We can write a flow designer which triggers when state is 'scheduled' and you can use 'Wait for a duration of time' with Duration type as Relative Duration to trigger email 15 min before the due date.

 

2. We can write a scheduled job which runs every few min and checks if due date is in next 15 min and trigger an event from job using gs.eventQueue

 

3. We can use gs.eventQueueScheduled method to trigger from your BR when state is 'scheduled'.

 

Syntax -

eventQueueScheduled(String name, Object glideRecord, String parm1, String parm2, Object expiration)

 

https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Glid...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

aryanjain25
Giga Guru

Hi @SandaminiM , you can try the following steps:

 

1. Navigate to Flow Designer:

   •Go to Flow Designer by typing “Flow Designer” in the search bar in ServiceNow.

   •Click on New to create a new flow.

2. Define the Trigger:

   •Select Record Updated as the trigger.

   •Choose the table where the task is stored. 

   • In the trigger condition, select:

       •Due Date is not empty.

3. Add a Wait Condition:

   • After setting up the trigger, add a Wait For Condition action.

   • Configure it to wait until 15 minutes before the due date.

4. Send Email Action:

   •If the condition is met, add the Send Email action.

   •In the “To” field, select assigned_to.email.

   •You can customize the subject and body of the email as per your requirement.

5. Save and Activate the Flow:

   •Once everything is set up, save and activate the flow.

 

aryanjain25_0-1727958878901.png

 

I would appreciate if you can mark this response as correct or helpful if it assisted you with your question.

 

Thanks,

Aryan Jain

 

View solution in original post

8 REPLIES 8

Yes Correct.

Make sure the trigger is properly set too.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

This worked!!! 😍

SandaminiM
Tera Contributor

Hi @Anwesha3 , @Rohini S Sane , @Voona Rohila ,

Thanks all! I will try these and get back to you!

aryanjain25
Giga Guru

Hi @SandaminiM , you can try the following steps:

 

1. Navigate to Flow Designer:

   •Go to Flow Designer by typing “Flow Designer” in the search bar in ServiceNow.

   •Click on New to create a new flow.

2. Define the Trigger:

   •Select Record Updated as the trigger.

   •Choose the table where the task is stored. 

   • In the trigger condition, select:

       •Due Date is not empty.

3. Add a Wait Condition:

   • After setting up the trigger, add a Wait For Condition action.

   • Configure it to wait until 15 minutes before the due date.

4. Send Email Action:

   •If the condition is met, add the Send Email action.

   •In the “To” field, select assigned_to.email.

   •You can customize the subject and body of the email as per your requirement.

5. Save and Activate the Flow:

   •Once everything is set up, save and activate the flow.

 

aryanjain25_0-1727958878901.png

 

I would appreciate if you can mark this response as correct or helpful if it assisted you with your question.

 

Thanks,

Aryan Jain