The CreatorCon Call for Content is officially open! Get started here.

Automatic SLA

vidishaagarwal5
Tera Contributor

Hi All,

 

How can we automatically calculate SLA duration based on the affected CI selected on the incident form?

Any suggestion, Script ??

2 ACCEPTED SOLUTIONS

M Iftikhar
Tera Sage

Hi @vidishaagarwal5,

You can also refer to this discussion where a similar issue was addressed:

Solved: SLA Calculation - ServiceNow Community

 

If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

View solution in original post

Ravi Gaurav
Giga Sage
Giga Sage

Hi @vidishaagarwal5 

As Suggested by @M Iftikhar check the Article : https://www.servicenow.com/community/developer-forum/sla-calculation/m-p/2675083
--------------

When it comes to Script use Business Rule :-

 

Script Example:

Table: incident
When: before insert / before update

 

 
(function executeRule(current, previous /*null when async*/) { // Get the affected CI var ci = current.cmdb_ci; if (ci) { var ciGR = new GlideRecord('cmdb_ci'); if (ciGR.get(ci)) { var slaHours = ciGR.u_sla_duration_hours || 8; // Default 8 hours if blank var gdt = new GlideDateTime(); gdt.addSeconds(slaHours * 3600); current.u_due_date = gdt; // Update your custom SLA due date field gs.info('SLA Duration set to ' + slaHours + ' hours for CI: ' + ciGR.name); } } })(current, previous);

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

3 REPLIES 3

M Iftikhar
Tera Sage

Hi @vidishaagarwal5,

You can also refer to this discussion where a similar issue was addressed:

Solved: SLA Calculation - ServiceNow Community

 

If my response helped, please mark it as the accepted solution so others can benefit as well.

 

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Ravi Gaurav
Giga Sage
Giga Sage

Hi @vidishaagarwal5 

As Suggested by @M Iftikhar check the Article : https://www.servicenow.com/community/developer-forum/sla-calculation/m-p/2675083
--------------

When it comes to Script use Business Rule :-

 

Script Example:

Table: incident
When: before insert / before update

 

 
(function executeRule(current, previous /*null when async*/) { // Get the affected CI var ci = current.cmdb_ci; if (ci) { var ciGR = new GlideRecord('cmdb_ci'); if (ciGR.get(ci)) { var slaHours = ciGR.u_sla_duration_hours || 8; // Default 8 hours if blank var gdt = new GlideDateTime(); gdt.addSeconds(slaHours * 3600); current.u_due_date = gdt; // Update your custom SLA due date field gs.info('SLA Duration set to ' + slaHours + ' hours for CI: ' + ciGR.name); } } })(current, previous);

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

vidishaagarwal5
Tera Contributor

Thanks @M Iftikhar  and @Ravi Gaurav  this helps