Name
sn_hr_core.hr_VANotificationUtilSNC
Description
Customers should not change this class directly, rather override methods in the subclass. This class is never called directly.
Script
var hr_VANotificationUtilSNC = Class.create();
hr_VANotificationUtilSNC.prototype = {
OLD_ER_TABLE: "sn_hr_core_case_relations",
initialize: function() {
this._hasRoleMaint = gs.hasRole('maint');
},
canEditNotification: function(currrentRecordSysId) {
var answer = false;
var hasRoleNotificationAdmin = gs.hasRole('notification_provider_admin');
var records = this._restrictedRecords();
if ((records.indexOf(currrentRecordSysId) >= 0 && this._hasRoleMaint) || (records.indexOf(currrentRecordSysId) < 0 && hasRoleNotificationAdmin))
answer = true;
return answer;
},
canEditNotificationContent: function(currrentRecordSysId){
var answer = false;
var hasRoleAdmin = gs.hasRole('admin');
var records = this._restrictedContentRecords();
if ((records.indexOf(currrentRecordSysId) >= 0 && this._hasRoleMaint) || (records.indexOf(currrentRecordSysId) < 0 && hasRoleAdmin))
answer = true;
return answer;
},
_restrictedRecords: function() {
var notificationRecords = ['9cae609e5352001050f4ddeeff7b12be', '8683cac55362001050f4ddeeff7b12d8', '1e4931c15362001050f4ddeeff7b1242', '9608b5815362001050f4ddeeff7b122e', '2b1a39c15362001050f4ddeeff7b12ff', 'faf4f1015362001050f4ddeeff7b123b', '2a5f1b0edb03c050505bc7a6059619f7', '8b4c243953a22010ff1fddeeff7b123a'];
// For support of legacy ER
if (this._tableExists(this.OLD_ER_TABLE))
notificationRecords.push('b801b18d5322001050f4ddeeff7b123a');
return notificationRecords;
},
_restrictedContentRecords: function() {
var contentRecords = ['6f0fa49e5352001050f4ddeeff7b120a', '5da30ec55362001050f4ddeeff7b125c', '63b7fd015362001050f4ddeeff7b12c1', '3d097d815362001050f4ddeeff7b1289', '89d975c15362001050f4ddeeff7b1285', '0a3ab9c15362001050f4ddeeff7b120b', '81bf5f0edb03c050505bc7a605961918', '48dc683953a22010ff1fddeeff7b125d'];
// For support for legacy ER
if (this._tableExists(this.OLD_ER_TABLE))
contentRecords.push('3d32b5cd5322001050f4ddeeff7b123a');
return contentRecords;
},
_tableExists: function(tableName) {
var gr = new GlideRecord(tableName);
return gr.isValid();
},
getHRTasksForNotification: function() {
var grTask = new GlideRecord('sn_hr_core_task');
grTask.addActiveQuery();
grTask.query();
var hrTasks = [];
while (grTask.next())
if (this._isTaskForNotification(grTask))
hrTasks.push(grTask.getUniqueValue());
return hrTasks;
},
/* Determine if a task should have a notification
* @param grTask {GlideRecord} The task to check for a notification
* @return {boolean} Whether the task should have a notification
*/
_isTaskForNotification: function(grTask) {
var parent = grTask.parent.getRefRecord();
while (parent && parent.isValidRecord()) {
var fulfillmentType = parent.getElement('hr_service.fulfillment_type').toString();
if (fulfillmentType === 'lifecycle_event' || fulfillmentType === 'journey')
return false;
parent = parent.parent.getRefRecord();
}
return true;
},
type: 'hr_VANotificationUtilSNC'
};
Sys ID
8c6d70215383001050f4ddeeff7b1275