Escalation Count value is not displaying in the banner

Sarah Bouil
Tera Expert

Escalation Count need to display dynamically but it is not displaying the Escalation Count so help me what is wrong on the below code.

 

Message: You are checking the incident as the incident ticket is escalated {} time(s).

 

HTML Code:

<div ng-if="data.isEscalated" class="escalation-message">
<p>You are checking the incident as the incident ticket is <span>{{data.escalationCount}}</span> time(s).</p>
</div>

 

Server Script:

(function() {
var escalationCount = 0;
var incidentSysId = $sp.getParameter('sys_id');
var incidentRecord = new GlideRecord('incident');
if (incidentRecord.get(incidentSysId)) {
gs.log('Incident record: ' + incidentRecord.number + ', Escalation Count: ' + incidentRecord.escalation);
escalationCount = incidentRecord.escalation || 0;
} else {
gs.log('Incident record with sys_id ' + incidentSysId + ' was not found.');
}
gs.log('Test01: ' + escalationCount);
data.isEscalated = escalationCount >= 1;
data.escalationCount = escalationCount;
gs.log('Test02: ' + data.escalationCount); // Escalation count is showing the correct count
gs.log('Test03: ' + data.isEscalated); // It is returning true
})();

 

What is missing and what is the error in my code?

1 REPLY 1

Kieran Anson
Kilo Patron

Hi Sarah,

When accessing a value on a GlideRecord, it's important to use getValue to avoid issues like what you're seeing. The following line needs to be changed

escalationCount = incidentRecord.escalation || 0;
//to
escalationCount = incidentRecord.getValue('escalation') || 0;