Name
sn_sow_on_call.OnCallEscalationCardSNC
Description
No description available
Script
var OnCallEscalationCardSNC = Class.create();
OnCallEscalationCardSNC.prototype = {
initialize: function(escalationLevel, type) {
if (escalationLevel) {
if (escalationLevel.level)
this.level = escalationLevel.level;
if (escalationLevel.total_time)
this.totalTime = escalationLevel.total_time;
if (escalationLevel.status)
this.status = escalationLevel.status;
if (escalationLevel.response_type)
this.response = escalationLevel.response_type;
if (escalationLevel.timer) {
var startGdt = new GlideDateTime();
var endGdt = new GlideDateTime();
endGdt.setDisplayValueInternal(escalationLevel.timer.display_value_internal);
if (startGdt.before(endGdt))
this.timerValue = parseInt((endGdt.getNumericValue() - startGdt.getNumericValue()) / 1000);
else
this.timerValue = 0;
}
}
this.type = type ? type : 'user';
},
setHeader: function(escalatee, type) {
this.header = {};
this.header.escalatee = escalatee;
this.header.escalateeType = type;
},
setSubheader: function(escalationLevel) {
this.subHeader = {};
if (this.header && this.header.escalatee && this.type == 'user') {
var userGr = new GlideRecord('sys_user');
if (!userGr.get(this.header.escalatee.sys_id))
return "";
this.subHeader.label = userGr.title + "";
this.subHeader.value = this._getUserLocation(userGr);
} else if (this.header && this.header.escalatee && this.type == 'device') {
var deviceEscalatee = this.header.escalatee;
this.subHeader.label = deviceEscalatee.type.display_value;
if (deviceEscalatee.type.value == 'Email') {
this.subHeader.value = deviceEscalatee.email_address.value;
} else if (deviceEscalatee.type.value == 'Voice' || deviceEscalatee.type.value == 'SMS')
this.subHeader.value = deviceEscalatee.phone_number.value;
}
},
acceptedCommunication: function(communication) {
this.acceptedComm = communication;
},
rejectedCommunication: function(communication) {
this.rejectedComm = communication;
},
addAttempt: function(attempt) {
if (this.completedAttempts) {
this.completedAttempts.push(attempt);
} else
this.completedAttempts = [attempt];
},
addPendingAttempt: function(attempt) {
if (this.pendingAttempts)
this.pendingAttempts.push(attempt);
else
this.pendingAttempts = [attempt];
},
_getUserLocation: function(userGr) {
var location = [];
if (userGr.location) {
if (userGr.location.city)
location.push(userGr.location.city.getDisplayValue());
if (userGr.location.state)
location.push(userGr.location.state.getDisplayValue());
}
return location.join(", ");
},
type: 'OnCallEscalationCardSNC'
};
Sys ID
c5e72430eb8b5110249e8d835d522801