Name
sn_oe_sfs.VACommonUtilities
Description
Common Utility Functions
Script
var VACommonUtilities = Class.create();
VACommonUtilities.prototype = {
initialize: function(channel) {
this.channel = channel;
this.inputBuilder = channel.inputBuilder;
this.logger = new sn_oe_sfs.VACommonLogger(this.inputBuilder.getChannelLogger(), 'VACommonUtilities');
this.logger.debug("VACommonUtilities channel: " + JSON.stringify(this.channel));
},
isChallengeURL: function(url) {
return url && (url.startsWith('ext:https://') || url.startsWith('ext:http://'));
},
getMaxUsersToPrelinkPerDay: function(preinstallLimitPerDayProp) {
var maxUsersToPreLinkPerDay = gs.getProperty(preinstallLimitPerDayProp, 10000);
maxUsersToPreLinkPerDay = parseInt(maxUsersToPreLinkPerDay);
if (maxUsersToPreLinkPerDay > 25000) {
maxUsersToPreLinkPerDay = 25000;
}
return maxUsersToPreLinkPerDay;
},
getMaxUsersToPreLinkPerBatch: function(preinstallLimitPerBatchProp) {
var maxUsersToPrelinkPerBatch = gs.getProperty(preinstallLimitPerBatchProp, 400);
maxUsersToPrelinkPerBatch = parseInt(maxUsersToPrelinkPerBatch);
return maxUsersToPrelinkPerBatch;
},
getPreLinkingBatchDelay: function(preinstallBatchDelayProp) {
var preLinkBatchDelayInSec = gs.getProperty(preinstallBatchDelayProp, 900);
preLinkBatchDelayInSec = parseInt(preLinkBatchDelayInSec);
return preLinkBatchDelayInSec;
},
getOutputFetchingDelay: function(preinstallFetchingDelayProp) {
var perBatchOutputFetchDelay = gs.getProperty(preinstallFetchingDelayProp, 1000);
perBatchOutputFetchDelay = parseInt(perBatchOutputFetchDelay);
return perBatchOutputFetchDelay;
},
getMaxWaitingForFetchingOutputs: function(preinstallMaxWaitingProp) {
var maxWaitingTimeInFetchingOutputs = gs.getProperty(preinstallMaxWaitingProp, 2700);
maxWaitingTimeInFetchingOutputs = parseInt(maxWaitingTimeInFetchingOutputs);
return maxWaitingTimeInFetchingOutputs;
},
isAutoLinkingEnabled: function(providerTable,providerSysID) {
var isAutolinkingFlagEnabled = false;
var providerGr = new GlideRecord(providerTable);
if (providerGr.get(providerSysID)) {
isAutolinkingFlagEnabled = providerGr.getValue('automatic_link_enabled');
return (isAutolinkingFlagEnabled === '1');
}
return isAutolinkingFlagEnabled;
},
doesProviderAppsExist: function(provider,providerSysID) {
provider = provider || providerSysID;
var providerAppGr = new GlideRecord('sys_cs_provider_application');
providerAppGr.addQuery('provider', provider);
providerAppGr.addNotNullQuery('message_auth');
providerAppGr.query();
return providerAppGr.next();
},
insertIntoIgnorePreLinkingTable: function(preLinkingTable,userId) {
var ignorePreLinkingGr = new GlideRecord(preLinkingTable);
ignorePreLinkingGr.initialize();
ignorePreLinkingGr.setValue('u_user', userId);
ignorePreLinkingGr.insert();
},
getUserEmail: function(userId) {
var email = '';
var gr = new GlideRecord('sys_user');
if (gr.get(userId)) {
email = gr.getValue('email');
}
return email;
},
type: 'VACommonUtilities'
};
Sys ID
cdbe935d870b59103a95426e0ebb35fb