Name

sn_risk_advanced.RiskAppetiteAjax

Description

No description available

Script

var RiskAppetiteAjax = Class.create();
RiskAppetiteAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
  type: 'RiskAppetiteAjax',
  verifyToleranceIsGreaterThanAppetite: function() {
      var type = this.getParameter('sysparm_modified_type');
      var value = this.getParameter('sysparm_value');
      var otherValue = this.getParameter('sysparm_other_value');
      var msg;

      switch (type) {
          case 'qual_appetite':
              if (this.checkQual(otherValue, value))
                  msg = gs.getMessage('The qualitative appetite should be less than the qualitative tolerance');
              break;
          case 'qual_tolerance':
              if (this.checkQual(value, otherValue))
                  msg = gs.getMessage('The qualitative tolerance should be greater than the qualitative appetite');
              break;
          case 'quant_appetite':
              if (this.checkQuant(otherValue, value))
                  msg = gs.getMessage("The quantitative appetite should be less than the quantitative tolerance");
              break;
          case 'quant_tolerance':
              if (this.checkQuant(value, otherValue))
                  msg = gs.getMessage("The quantitative tolerance should be greater than the quantitative appetite");
              break;

      }
      return msg;
  },

  getScaleValue: function(sysId) {
      var scale = new GlideRecord('sn_risk_advanced_risk_appetite_scale');
      scale.get(sysId);
      return scale.value;
  },

  checkQual: function(tolerance, appetite) {
      return this.getScaleValue(appetite) > this.getScaleValue(tolerance);
  },

  checkQuant: function(tolerance, appetite) {
      var gr = new GlideRecord("sn_risk_definition");
      gr.setValue("quant_tolerance", tolerance);
      gr.setValue("quant_appetite", appetite);
      return parseFloat(gr.quant_appetite.getReferenceValue()) > parseFloat(gr.quant_tolerance.getReferenceValue());
  }
});

Sys ID

9140d9d1778a1110c4a4b0bdbd5a9967

Offical Documentation

Official Docs: