sla breach time need to be changed based on day/night

Ak8977
Tera Expert

Response for P1need to be changed.
If the incident is created between 9 AM pm to 6 PM, then it should be 15mins else it would be 30 mins. Is it possible. If yes how I can do it. 

6 REPLIES 6

Rajdeep Ganguly
Mega Guru


Yes, it is possible to change the response time for P1 incidents based on the time they are created in ServiceNow. You can achieve this by creating a business rule that sets the desired response time based on the incident creation time. Here are the steps:

1. Navigate to System Definition > Business Rules.
2. Click on New to create a new business rule.
3. Give your business rule a name, for example, "Set Response Time for P1 Incidents".
4. In the "When to run" section, select "before" in the "When" dropdown and "insert, update" in the "Insert, Update" dropdown.
5. In the "Conditions" section, set the condition to run this rule only for P1 incidents. For example, "When Priority is 1".
6. In the "Script" section, write a script that checks the incident creation time and sets the response time accordingly. Here is a sample script:

javascript
(function executeRule(current, previous /*null when async*/) {
var createdOn = current.sys_created_on.getGlideObject();
var createdHour = createdOn.getByFormat('HH');
if (createdHour >= 9 && createdHour <= 18) {
// Set response time to 15 minutes if incident is created between 9 AM and 6 PM
current.u_response_time = 15;
} else {
// Set response time to 30 minutes if incident is created outside of 9 AM to 6 PM
current.u_response_time = 30;
}
})(current, previous);


7. Click on Submit to save the business rule.

Please note that the above script assumes that you have a custom field "u_response_time" on the incident table to store the response time. If you are using a different field, please replace "u_response_time" with your field name. Also, the time is considered in 24-hour format.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

AshishKM
Kilo Patron
Kilo Patron

Hi @Ak8977 , 

Agreed with @Dr Atul G- LNG and @AndersBGS , create 2 separate SLA based on time slot and keep it simple.

 

Alternatively, if your org don't allow to create separate SLA, you can create scheduled job to change this response time everyday, however it is not a good idea for SLA reporting metric purpose. 

 

Scheduled Job Run @6PM and check if response time =15m then change it to 30m

Scheduled Job Run @9AM and check if response time =30m then change it to 15m

 

-Thanks,

AshishKM

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution