Send An Email Reminder Based On a Variable Date Field

GamNOW
Tera Contributor

Hello ServiceNow Community,

 

I am looking to achieve a requirement that simply sends an email notification 60 days before the due date. based on:

 

Variable type: Date

Tech name: due_date

 

Requirement: Send a email notification if today's date reaches 60 days or less before the due date. 

 

What's an efficient way to develop this? I figured a scheduled job would suit my case. But how would you query the variable and its value? So that if these conditions meet, send out an notification that contains a link to the RITM.

 

Thank you! 

 

 

1 ACCEPTED SOLUTION

Matthew_13
Mega Sage

Yes my friend — a scheduled job is the right way to do this, especially since your “due date” is a catalog variable.

What I’d do:

  1. Add a real date field on the RITM (example: u_due_date) and a simple flag like u_60_day_notice_sent.

  2. Copy the variable value into that field when the RITM is created (or when the variable changes). This avoids having to query the variable tables every day.

  3. Create a Scheduled Script Execution that runs daily and finds RITMs where:

    • u_due_date is within the next 60 days, and

    • u_60_day_notice_sent is false

  4. For each match, trigger an event or send directly and include a link to the RITM in the email.

  5. Set the flag to true so the user doesn’t get the same email again tomorrow.

That approach is much simpler than querying sc_item_option_mtom for the variable value on every run, and it scales better.

 

@GamNOW  - Please mark Accepted Solution and Thumbs Up if you found Helpful 🙂

MJG

View solution in original post

3 REPLIES 3

Matthew_13
Mega Sage

Yes my friend — a scheduled job is the right way to do this, especially since your “due date” is a catalog variable.

What I’d do:

  1. Add a real date field on the RITM (example: u_due_date) and a simple flag like u_60_day_notice_sent.

  2. Copy the variable value into that field when the RITM is created (or when the variable changes). This avoids having to query the variable tables every day.

  3. Create a Scheduled Script Execution that runs daily and finds RITMs where:

    • u_due_date is within the next 60 days, and

    • u_60_day_notice_sent is false

  4. For each match, trigger an event or send directly and include a link to the RITM in the email.

  5. Set the flag to true so the user doesn’t get the same email again tomorrow.

That approach is much simpler than querying sc_item_option_mtom for the variable value on every run, and it scales better.

 

@GamNOW  - Please mark Accepted Solution and Thumbs Up if you found Helpful 🙂

MJG

Hello @Matthew_13  and @Stefan Reichelt 

 

Thank you. I applied this solution with some differences but I was able to achieve the result I'm looking for.

 

I made a custom table that grabs information from the RITM/SCTASKs and writes it to the custom table.  The columns contained start/end dates and I have a scheduled job that looks at the value of the end date.  I made a conditional check so that if the date falls under 60 days, send an email and update a checkbox to true (Checkbox to ensure only one email is sent).  

 

Thank you both for you input. 

 

-Gam

Stefan Reichelt
Kilo Sage

You can also get it done within a Flow for each record (depending on the volume of records). Add the Flow logic "Wait for a duration of time", and then either "Send Email" or "Send Notification".