- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 01:55 AM
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 !!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:01 AM - edited 10-03-2024 02:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:05 AM - edited 10-03-2024 02:07 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:23 AM
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)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 05:38 AM - edited 10-03-2024 05:39 AM
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.
I would appreciate if you can mark this response as correct or helpful if it assisted you with your question.
Thanks,
Aryan Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:01 AM - edited 10-03-2024 02:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:05 AM - edited 10-03-2024 02:07 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:23 AM
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)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 02:36 AM
Hi @Voona Rohila ,
I am trying your first method. Is the following configurations are correct?