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

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Shraddha Desai1 ,
I trust you are doing great.

To achieve the desired 75% SLA notification for change management in ServiceNow, we can use the SLA (Service Level Agreement) functionality along with a workflow. Here's a step-by-step solution:

  1. Define an SLA definition:

    • Go to the Service Level Management application in ServiceNow.
    • Create a new SLA definition for the change management process.
    • Set the SLA percentage to 75%.
  2. Define an SLA workflow:

    • Navigate to the SLA Workflow tab in the SLA definition.
    • Create a new workflow or select an existing one.
    • Specify the conditions for the SLA to start and stop based on the 'plan start' and 'end date.'
    • Calculate the total hours between the 'plan start' and 'end date.'
    • Subtract the 'plan start' and 'end date' difference from the total hours calculated.
    • Add 8 hours to the result obtained in the previous step.
  3. Configure the notification:

    • Within the SLA workflow, add a notification action at the desired stage.
    • Specify the notification recipient(s), such as the change manager or relevant stakeholders.
    • Craft the notification content, including the necessary information about the change and its SLA status.
    • Customize the notification template to align with your company's branding and tone.
  4. Test the SLA:

    • Create a test change request in the ServiceNow instance.
    • Observe the SLA workflow execution and ensure that the notifications are triggered according to the defined percentage and conditions.

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Hello @Amit Gujarathi 

Thank You so much for the solution.

Can you please provide us the 'total hours between the 'plan start' and 'end date' calculation script and 'Subtract the 'plan start' and 'end date' difference from the total hours' calculation script?

 

Thank You!

HI @Shraddha Desai1 ,

Please find below code for the same.

 

// Assuming 'gr' is the GlideRecord object representing the change request record

var planStart = new GlideDateTime(gr.getValue('start_date')); // Assuming 'start_date' is the field name for the plan start date
var planEnd = new GlideDateTime(gr.getValue('end_date')); // Assuming 'end_date' is the field name for the plan end date

var difference = planEnd.getNumericValue() - planStart.getNumericValue();
var hoursDifference = Math.floor(difference / (1000 * 60 * 60)); // Convert milliseconds to hours

// You can then use the 'hoursDifference' variable in your formula for the SLA calculation

 

Please mark the solution correct


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Hello @Amit Gujarathi 

Please see my code and let me what I am doing wrong. It is not working

******************************

var gr = new GlideRecord('change_request');
gr.addQuery('number', current.sys_id);
gr.query();
if (gr.next()) {
var planStart = new GlideDateTime(gr.getValue('start_date'));
var planEnd = new GlideDateTime(gr.getValue('end_date'));
var difference = planEnd.getNumericValue() - planStart.getNumericValue();
var hoursDifference = Math.floor(difference / (1000 * 60 * 60));
var eighthr = hoursDifference + 8;

var rec = [];
rec.push(current.task.assigned_to);
return rec;
}

*****************************