How to trigger a notification if follow update is greater then current date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 06:19 AM
We have a date field "Follow up" in incident form that gets filled by the helpdesk analyst, as per the requirement system should auto trigger a notification to the manager if current date is greater then the date "follow up.
Please suggest the script that i can use to achive this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 06:47 AM
To achieve this requirement in ServiceNow, you can create a Business Rule that runs when a record is inserted or updated and checks if the "Follow up" date is in the past. If it is, the rule can trigger a notification to the manager, below is sample BR:
(function executeRule(current, previous /*null when async*/) {
// Check if Follow up date is in the past
var followUpDate = current.follow_up;
var currentDate = new GlideDateTime();
if (followUpDate < currentDate) {
// Trigger notification to manager
var manager = current.manager; // Assuming manager field exists in your incident table
if (manager) {
gs.eventQueue('incident.follow_up_past', current, manager);
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 06:49 AM
No script. Just use the flow designer. Trigger on 'follow up' is filled, add a wait condition for the 'follow up' date and send the notification at that time (or maybe a bit of time after it, assuming you want the analyst to have time to follow up).
It wouldn't hurt to put an extra check in there (depending on the process) to see if the ticket is still active at that date.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 06:50 AM
how about an on update Business Rule which triggers event, then using the same event to trigger an email notification.
the BR script may look like:
var gd= new GlideDate();
var gdc= new GlideDate();
gd.setValue(current.follow_up);
if(gd.compareTo(gdc)==0 || gd.compareTo(gdc)==1)
{
gs.eventQueue('event_name',current,current.param1,current.param2);
}
feel free to change this code as per your convenience, you may paste this code inside your BR function.
if this helped resolving your query, please be sure to mark this as accepted and also helpful.
regards,
Ubada Barmawar.