Name
sn_rf.RFRecordDisplayConfigurationService
Description
Class for sn_rf_record_display_configuration table utility functions.
Script
var RFRecordDisplayConfigurationService = Class.create();
RFRecordDisplayConfigurationService.prototype = {
tableName: RFConstants.tables.SN_RF_RECORD_DISPLAY_CONFIGURATION,
initialize: function(grOrSysId, forRecord) {
if (grOrSysId && grOrSysId.sys_class_name == this.tableName) {
this.currentRecord = grOrSysId;
} else if (grOrSysId) {
var gr = new GlideRecord(this.tableName);
if (gr.get(grOrSysId)) {
this.currentRecord = gr;
}
}
this.forRecord = forRecord;
},
hasValidRecord: function() {
return this.currentRecord && this.currentRecord.sys_class_name == this.tableName &&
this.forRecord && this.forRecord.getTableName() == this.getTable();
},
getTable: function() {
return this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_TABLE);
},
getCardLabel: function() {
return this.currentRecord.getDisplayValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_CARD_LABEL) || "";
},
getCardTitle: function() {
return this._getDisplayValue(this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_CARD_TITLE));
},
getCardDescription: function() {
return this._getDisplayValue(this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_CARD_DESCRIPTION_FIELD));
},
getCardAdditionalFields: function() {
var additionalFieldsConfigured = this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_CARD_ADDITIONAL_FIELDS);
return this._getAdditionalFields(additionalFieldsConfigured);
},
getCardDisplayFooter: function() {
var displayFooter = this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_CARD_DISPLAY_FOOTER);
var displayValue = "";
if (displayFooter == "1") {
var updatedOn = this.forRecord.getValue(RFConstants.fields.SYS_UPDATED_ON);
displayValue = gs.getMessage("Updated {0}", RFUtils.timeAgo(new GlideDateTime(updatedOn)));
}
return displayValue;
},
isDefaultDetailView: function() {
return this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_DEFAULT_DETAIL_VIEW) == "1";
},
getDetailTitle: function() {
return this._getDisplayValue(this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_DETAIL_TITLE_FIELD));
},
getDetailLink: function() {
return this._getDisplayValue(this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_DETAIL_LINK_FIELD));
},
getDetailAdditionalFields: function() {
var additionalFieldsConfigured = this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_DETAIL_ADDITIONAL_FIELDS);
return this._getAdditionalFields(additionalFieldsConfigured);
},
getDetailDisplayWorkNote: function() {
var displayLastWorkNote = this.currentRecord.getValue(RFConstants.fields.SN_RF_RECORD_DISPLAY_CONFIGURATION_DETAIL_DISPLAY_WORK_NOTE);
var lastWorkNote = "";
if (displayLastWorkNote == "1") {
var grInc = new GlideRecord(RFConstants.tables.SYS_JOURNAL_FIELD);
grInc.addQuery(RFConstants.fields.SYS_JOURNAL_FIELD_ELEMENT_ID, this.forRecord.getValue(RFConstants.fields.SYS_ID));
grInc.addQuery(RFConstants.fields.SYS_JOURNAL_FIELD_ELEMENT, "work_notes");
grInc.orderByDesc(RFConstants.fields.SYS_CREATED_ON);
grInc.query();
if (grInc.next()) {
lastWorkNote = grInc.getDisplayValue(RFConstants.fields.SYS_JOURNAL_FIELD_VALUE);
}
}
return lastWorkNote;
},
_getDisplayValue: function(field) {
if (field) {
return this.forRecord.getDisplayValue(field) || "";
}
return "";
},
_getAdditionalFields: function(additionalFieldsConfigured) {
var additionalFields = [];
if (additionalFieldsConfigured) {
additionalFieldsConfigured = additionalFieldsConfigured.split(',') || [];
for (var idx = 0; idx < additionalFieldsConfigured.length; idx++) {
var fieldName = additionalFieldsConfigured[idx];
var value = this._getDisplayValue(fieldName);
additionalFields.push({
"name": fieldName,
"label": this.forRecord[fieldName].getLabel(),
"value": value
});
}
}
return additionalFields;
},
type: 'RFRecordDisplayConfigurationService'
};
Sys ID
e335b6cdc7733010dd7ab6c427c26097