Name

sn_risk_advanced.RiskUtilityAjax

Description

No description available

Script

var RiskUtilityAjax = Class.create();
RiskUtilityAjax.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
  getContributingRisks: function() {
      var reportSysId = this.getParameter('sysparm_sys_id');
      var report = new GlideRecord("sn_risk_advanced_risk_report");
      report.get(reportSysId);
      return new RiskUtilities().getContributingRisks(report);
  },

  getContributingEvents: function() {
      var recordSysId = this.getParameter('sysparm_sys_id');
      return new GRCRiskEvent().getContributingEvents(recordSysId);
  },

  checkRiskChildProfileAssociation: function(profileID) {
      return this._checkRiskChildProfileAssociation(profileID);
  },

  getCurrencyCode: function() {
      return new GRCRiskEvent().getCurrencyCode();
  },

  /*
  	checks if the given profile has associated risk statements or it has any active downstream 
  	profiles in order to copy the tolerance values from any of these where profile's risk statement 
  	takes precedence
  */
  _checkRiskChildProfileAssociation: function(profileID) {
      var risks = new GlideRecord('sn_risk_risk');
      risks.addQuery('profile', profileID);
      risks.addQuery('state', '!=', 'retired');
      risks.addNotNullQuery('content');
      risks.setLimit(1);
      risks.query();
      if (risks.hasNext())
          return "risk_statements";
      else {
          var profilem2m = new GlideRecord('sn_grc_m2m_profile_profile');
          var downstream_profile;
          profilem2m.addQuery('upstream_profile', profileID);
          profilem2m.query();
          while (profilem2m.next()) {
              downstream_profile = profilem2m.downstream_profile;
              if (downstream_profile.active) {
                  return "child_profiles";
              }
          }
      }
      return "";
  },

  changeStateOfRisk: function() {
      if (gs.hasRole("sn_risk.user")) {
          var state = this.getParameter('sysparm_state');
          var riskGr = new GlideRecord("sn_risk_risk");
          if (riskGr.get(this.getParameter('sysparm_risk_id'))) {
              riskGr.state = state;
              if (state == 'retired')
                  riskGr.retired_manually = true;
              riskGr.update();
          }
      }
  },

  type: 'RiskUtilityAjax'
});

Sys ID

1d1a9032b74033002a279e98ee11a9d9

Offical Documentation

Official Docs: