Retrieve SLA Business Percentage (task_sla) in Incident Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2024 12:29 PM
Hello everyone,
I need to retrieve the information from the `business_percentage` field in the `task_sla` table to populate the `u_sla` field in the Incident form. If possible, I would like to retrieve the graphical representation with the percentage, but the graphical representation itself is not mandatory.
I have already tried creating an "on after" business rule on the `task_sla` table with the following script, but it doesn’t work:
To clarify, the `u_sla` field in the Incident table is of the `duration` type.
Business rule script:
(function executeRule(current, previous /*null when async*/) {
if (current.task.sys_class_name == 'incident') {
if (current.business_percentage) {
var incidentGR = new GlideRecord('incident');
if (incidentGR.get(current.task.sys_id)) {
incidentGR.u_sla = current.business_percentage; // transferring business_percentage to u_sla field
incidentGR.update();
}
}
}
})(current, previous);
```
The goal is to retrieve the SLA displayed at the bottom of the Incident form and show it in the form, as it is displayed at the bottom (though that part is not too important).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 05:12 AM
SLAs have been created for a specific incident typology, and there will always be only one SLA for this type of incident. For the type field, I used the "percent complete" field to display percentages. I personally don't find the requirement very useful, but I was asked to implement it. After adding logs, I'm not retrieving anything in current.business_percentage, and I'm not sure why.
Thanks