How to send SLA notification on start and end date difference?

Shraddha Desai1
Tera Contributor

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

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



Hello @Amit Gujarathi ,

 

  • How much duration do we need to add in duration field of SLA?

Thank you!