Automatic SLA

vidishaagarwal5
Tera Expert

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

miftikhar20
Kilo Patron

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.

 

View solution in original post

Ravi Gaurav
Giga Sage

Hi @vidishaagarwal5 

As Suggested by @miftikhar20 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);

 

View solution in original post

3 REPLIES 3

miftikhar20
Kilo Patron

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.

 

Ravi Gaurav
Giga Sage

Hi @vidishaagarwal5 

As Suggested by @miftikhar20 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);

 

vidishaagarwal5
Tera Expert

Thanks @miftikhar20  and @Ravi Gaurav  this helps