Retrieve SLA Business Percentage (task_sla) in Incident Form

nabil
Tera Contributor

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).

 

1 ACCEPTED SOLUTION

This really should be one of those requirements where it's pushed back as a non-value deliverable. Has your customer started to use Service Operations Workspace? The SLAs can be setup to be displayed on the sidebar which provides easier visibility.

 

Alternatively, I'd use an on display business rule to add an information message if they're wanting the SLA % to be available purely for human visibility, not reporting purposes. 

View solution in original post

3 REPLIES 3

Kieran Anson
Kilo Patron

I'd strongly discourage this sort of customisation. The elapsed percentage is a constantly changing number and you'll be doing a lot of updates. These values also don't update until the record is queried/viewed so it won't always be an accurate representation. A task record can also have multiple SLAs

nabil
Tera Contributor

Thanks you for your response.

The requirement is as follows
: 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.

This really should be one of those requirements where it's pushed back as a non-value deliverable. Has your customer started to use Service Operations Workspace? The SLAs can be setup to be displayed on the sidebar which provides easier visibility.

 

Alternatively, I'd use an on display business rule to add an information message if they're wanting the SLA % to be available purely for human visibility, not reporting purposes.