Trigger a notification when the date is one day before variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 05:56 AM
Hello,
We have offboarding tasks that sometimes get created 6 months or longer before the accounts actually need to get offboarded. What I am hoping to achieve is to be able to send an e-mail to assignment group 'User Account Management' on table sc_task when:
Assignment group = User Account Management
Short description starts with please deactivate AD
Current date is one day before date on requested item (name=Offboarding SF) variable = termination_date.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 06:02 AM
The only way to do this would be a Scheduled Job that triggers an event which triggers a notification for each record that meets that criteria or a Flow that runs daily and checks for records that meet that criteria and sends the emails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 02:37 AM
To send an email notification to the User Account Management group under the specific conditions, you can create a scheduled script in ServiceNow. The script will check tasks in the sc_task table where the assignment group is User Account Management, the short description starts with "please deactivate AD," and the current date is one day before the termination_date variable in the associated requested item (Offboarding SF).
The script would run daily, query the tasks meeting these criteria, and for each matching record, retrieve the related requested item. From there, it would check if the termination_date is one day away. If it is, the script would send an email notification to the group as a reminder.
Once you’ve written the script, test it in a safe environment to ensure it works as expected and only sends emails when all the conditions are met. After testing, schedule it to run daily at a time that ensures the notifications are timely. This way, you can automate reminders and make sure no critical offboarding tasks are missed.
CMIIW 🙂
Heaven guardian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 04:59 AM
You have 2 broad strategies:
Strat1 - Integrate the wait time and notification into the task's flow.
Strat2 - Have a single mechanism that runs daily against all these tasks
Given the LONG timelines involved, I'd opt for strategy 2. Now, how to execute. I always look to Flow first because its easy to set up and easy to inherit, especially for low-code admins.
TRIGGER: Scheduled (daily)
1) Look Up Records (offboarding tasks)
--- where variables.termination_date = today
--- plus your other conditions too
2) For Each of (1)
3) Send Notification (NOT email, and NOT event)
I'm very very specific about the method in (3) because Send Notification is just plain better.
Define your notification just like you would any other for a specific task.
Cut out the event middleman. Here's a video that goes deeper, starting you right at the timestamp you need.
https://youtu.be/FtOT4aDs7lo?si=yd5fAsm6j_P9_O7n&t=322