How to send SLA notification on start and end date difference?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 11:02 AM
Hello,
We want to send 75% SLA notification for change management for 'plan start and end date total hours - (plan start end date difference)+8hr.'
How we can do this by using SLA or SLA workflow in ServiceNow ?
Thank You!
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 04:03 AM
Hi @Shraddha Desai1 ,
You can try below code for the same
var planStart = new GlideDateTime(current.start_date);
var planEnd = new GlideDateTime(current.end_date);
var difference = planEnd.getNumericValue() - planStart.getNumericValue();
var hoursDifference = Math.floor(difference / (1000 * 60 * 60));
var eighthr = hoursDifference + 8;
var threshold = 0.75 * eighthr; // Calculate the 75% threshold
if (current.state.changes()) {
// Check if the state of the change request has changed
var rec = [];
if (current.state == 'in_progress' && current.schedule_percentage >= threshold) {
// Add the assigned_to user to the recipients list if the progress exceeds the threshold
rec.push(current.task.assigned_to);
}
return rec;
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 01:50 AM