Name
sn_grc.EntitlementUtils
Description
No description available
Script
var EntitlementUtils = Class.create();
EntitlementUtils.prototype = {
initialize: function() {},
canDeleteEntityType: function() {
var retValue = true;
if (!this._isHavingFullGRCEntitlement() && !this._isHavingESGEntitlement())
retValue = false;
return retValue;
},
trackAsLiteUser: function() {
var retValue = true;
if (!this._isHavingLiteUserEntitlement())
retValue = false;
return retValue;
},
canCreateProfile: function(tableName) {
return this.canCreateProfileFilter(tableName);
},
canCreateProfileFilter: function(tableName) {
var retValue = true;
if (!this._isHavingFullGRCEntitlement() && !this._isHavingESGEntitlement()) {
retValue = this._isAllowed(tableName);
}
return retValue;
},
canCreateProfileType: function() {
var retValue = true;
if (!this._isHavingFullGRCEntitlement() && !this._isHavingESGEntitlement())
retValue = false;
return retValue;
},
isHavingOnlyESGEntitlement: function() {
return this._isHavingFullGRCEntitlement() ? false : this._isHavingESGEntitlement();
},
//This method is used to load tables in Profile Filter form using tableChoiceScript attribute
//Name of this method should not be changed because tableChoiceScript uses a method with name process to figure out list of tables
process: function() {
var tableNames = [];
if (this._isHavingFullGRCEntitlement() || this._isHavingESGEntitlement()) {
tableNames.push.apply(tableNames, this._getAllTables());
} else {
tableNames.push.apply(tableNames, this._getAllowedTablesForFCAEntitlement());
}
return tableNames;
},
_isAllowed: function(tableName) {
var fcaTables = this._getAllowedTablesForFCAEntitlement();
for (var i = 0; i < fcaTables.length; i++) {
if (fcaTables[i] == tableName) {
return true;
}
}
return false;
},
_getAllTables: function() {
var tableNames = [];
var sysDbObject = new GlideRecord('sys_db_object');
sysDbObject.addEncodedQuery('sys_update_nameISNOTEMPTY');
sysDbObject.query();
while (sysDbObject.next()) {
tableNames.push(sysDbObject.getValue('name'));
}
return tableNames;
},
_getAllowedTablesForFCAEntitlement: function() {
return gs.getProperty('sn_grc.allowed_fca_tables').split(',');
},
_isHavingFullGRCEntitlement: function() {
try {
return sn_lef.GlideEntitlement.hasLicenseEntitlementForApp('sn_grc', 'grc_full_access');
} catch (err) {
gs.error(gs.getMessage('Error in reading the entitlement information.'), err);
return true;
}
},
_isHavingLiteUserEntitlement: function() {
try {
return sn_lef.GlideEntitlement.hasLicenseEntitlementForApp('sn_risk_advanced', 'sn_irm_lite_risk_assessment');
} catch (err) {
gs.error(gs.getMessage('Error in reading the entitlement information.'), err);
return true;
}
},
_isHavingESGEntitlement: function() {
try {
return sn_lef.GlideEntitlement.hasLicenseEntitlementForApp('sn_grc', 'grc_esg_limited');
} catch (err) {
gs.error(gs.getMessage('Error in reading the entitlement information.'), err);
return true;
}
},
type: 'EntitlementUtils'
};
Sys ID
696319000f503300bad14bb768767e1c