- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Hi All,
How can we automatically calculate SLA duration based on the affected CI selected on the incident form?
Any suggestion, Script ??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
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.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago - last edited 10 hours ago
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
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.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago - last edited 10 hours ago
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Thanks @M Iftikhar and @Ravi Gaurav this helps