Name
sn_oe_sfs.IARIssueNotAssignedDiagnostic
Description
Contains functions that assist with diagnosing IAR issues where a task is not being assigned to a bot user
Script
var IARIssueNotAssignedDiagnostic = Class.create();
IARIssueNotAssignedDiagnostic.prototype = {
initialize: function() {},
type: 'IARIssueNotAssignedDiagnostic'
};
/**
* @param the number of a task
* @returns {sys_id, config_table_name}, or null if task is not found
*/
IARIssueNotAssignedDiagnostic.findTask = function(task_number) {
var grTask = new GlideRecord("task");
grTask.addQuery("number", vaInputs.task_number);
grTask.query();
if (grTask.getRowCount() == 1) {
grTask.next();
var result = {};
result.sys_id = grTask.sys_id;
result.config_table_name = grTask.sys_class_name;
return result;
} else {
return null;
}
};
/**
* @param the table name of an IAR configuration, i.e. sn_hr_core_case_payroll
* @returns sys_id of config, or null if config is not found
*/
IARIssueNotAssignedDiagnostic.findConfig = function(config_table_name) {
var grConfig = new GlideRecord("sys_cs_auto_resolution_configuration");
grConfig.addQuery("target_table_name", config_table_name);
grConfig.query();
if (grConfig.getRowCount() == 1) {
grConfig.next();
return grConfig.sys_id;
}
return null;
};
/**
* @param the sys_id of an IAR configuration
* @returns the sys_id of the business rule associated with the IAR configuration, or null if there is none
*/
IARIssueNotAssignedDiagnostic.checkBrExists = function(config_sys_id) {
var grConfig = new GlideRecord("sys_cs_auto_resolution_configuration");
grConfig.get(config_sys_id);
if (!gs.nil(grConfig.business_rule)) {
return grConfig.business_rule;
}
return null;
};
/**
* @param the sys_id of a business rule
* @returns a boolean representing whether the business rule is active
*/
IARIssueNotAssignedDiagnostic.checkBrActive = function(br_sys_id) {
var grBusinessRule = new GlideRecord("sys_script");
grBusinessRule.get(br_sys_id);
return grBusinessRule.active;
};
/**
* @param the sys_id of a business rule
* @returns a boolean representing whether the business rule has the highest possible order
*/
IARIssueNotAssignedDiagnostic.checkBrOrderIsHighest = function(br_sys_id) {
var grBusinessRule = new GlideRecord("sys_script");
grBusinessRule.get(br_sys_id);
// 2147483647 - Need to first fix this on the product side
return grBusinessRule.order >= 99999;
};
/*
* @param the sys_id of a business rule associated with the IAR configuration
* @param the table name of the IAR configuration, i.e. sn_hr_core_case_payroll
* @returns a boolean representing whether the configuration has only 1 business rule associated with it
*/
IARIssueNotAssignedDiagnostic.checkConfigHasOneBr = function(br_sys_id, config_table_name) {
var grBusinessRule = new GlideRecord("sys_script");
grBusinessRule.get(br_sys_id);
var grAllBusinessRules = new GlideRecord("sys_script");
grAllBusinessRules.addQuery("name", grBusinessRule.name);
grAllBusinessRules.addQuery("collection", config_table_name);
grAllBusinessRules.query();
return grAllBusinessRules.getRowCount() == 1;
};
/*
* @param the sys_id of the task
* @param the sys_id of the IAR configuration
* @param the table name of the IAR configuration, i.e. sn_hr_core_case_payroll
* @returns whether the task conditions and IAR trigger configuration match
*/
IARIssueNotAssignedDiagnostic.checkTaskAndConfigConditionsMatch = function(task_sys_id, config_sys_id, config_table_name) {
var grConfig = new GlideRecord("sys_cs_auto_resolution_configuration");
grConfig.get(config_sys_id);
var grTask = new GlideRecord(config_table_name);
grTask.get(task_sys_id);
return GlideFilter.checkRecord(grTask, grConfig.condition);
};
/*
* @param the sys_id of an IAR configuration
* @returns the name of the bot user that tasks under that configuration are assigned to
*/
IARIssueNotAssignedDiagnostic.getTaskAssignedTo = function(config_sys_id) {
var grConfig = new GlideRecord("sys_cs_auto_resolution_configuration");
grConfig.get(config_sys_id);
return grConfig.getDisplayValue("assign_to");
};
Sys ID
76fec17dc0e1d5d0f877e9d0ea777a12