213 views

Description

The Change Request impact value is not updating when the Risk Condition 'Use script values' is set to true and the script updates the impact via current.

Steps to Reproduce

1. Create a Risk Condition as followsL
- 'Use script values' enabled
- Script:
current.risk = 3 ; // 2 -high, 3 - moderate, 4-low
current.impact =1; // 1-high, 2-medium, 3-low

2. Create a Normal Change Request as follows:
- Risk = High
- Impact = Low
- Short Description = "SNC TEST"

3. Run the risk assessment with first choice as answer for all questions. The Impact fails to be set to High, and remains Low.

Workaround

This problem has been fixed. If you are able to upgrade, review the Fixed In section to determine the latest version with a permanent fix your instance can be upgraded to.

The workaround on previous versions consisted in adding the scripts below.

- Add to RiskCalculator:

	calculateRiskConditions: function() {
		var evaluatedRiskImpact = this.calculateRisk();
		if (!evaluatedRiskImpact || !evaluatedRiskImpact.riskCondition)
			return {};

		evaluatedRiskImpact.riskCondition.msg = evaluatedRiskImpact.riskCondition.msg ? evaluatedRiskImpact.riskCondition.msg += ": " + gs.getMessage("Risk Condition calculated") : gs.getMessage("Risk Condition calculated");

		if (evaluatedRiskImpact.riskCondition && evaluatedRiskImpact.riskCondition.name && evaluatedRiskImpact.riskCondition.name.value)
			evaluatedRiskImpact.riskCondition.msg += ": " + '' +
				GlideStringUtil.escapeHTML(evaluatedRiskImpact.riskCondition.name.display_value || evaluatedRiskImpact.riskCondition.name.value).replaceAll('"', '"') + "";

		evaluatedRiskImpact.riskEvaluation = {};

		if (evaluatedRiskImpact.riskCondition.risk && (evaluatedRiskImpact.riskCondition.risk.value || evaluatedRiskImpact.riskCondition.risk.value === 0) && !isNaN(evaluatedRiskImpact.riskCondition.risk.value)) {
			evaluatedRiskImpact.riskEvaluation.risk = evaluatedRiskImpact.riskCondition.risk;
			evaluatedRiskImpact.riskEvaluation.risk.updated = parseInt(evaluatedRiskImpact.riskCondition.risk.value) !== parseInt(this.changeRequestGr.risk) || this.changeRequestGr.risk.changes();
			evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Risk: {0}{1}{2}", [this.getStartColorTag(), evaluatedRiskImpact.riskCondition.risk.display_value || evaluatedRiskImpact.riskCondition.risk.value, this.getEndColorTag()]);
		} else {
			// If the Risk is "Leave Alone" then populate risk with the change request risk value
			evaluatedRiskImpact.riskEvaluation.risk = {
				value: this.changeRequestGr.risk.nil() ? "" : this.changeRequestGr.risk + "",
				display_value: this.changeRequestGr.risk.getDisplayValue() + "",
				updated: false
			};
			evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Risk unchanged");
		}

		// risk conditions may also set impact
		if (evaluatedRiskImpact.riskCondition.impact && evaluatedRiskImpact.riskCondition.impact.value) {
			evaluatedRiskImpact.riskEvaluation.impact = evaluatedRiskImpact.riskCondition.impact;
			evaluatedRiskImpact.riskEvaluation.impact.updated = this.changeRequestGr.impact + "" !== evaluatedRiskImpact.riskCondition.impact.value + "" || this.changeRequestGr.impact.changes();
			evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Impact: {0}{1}{2}", [this.getStartColorTag(),  evaluatedRiskImpact.riskCondition.impact.display_value || evaluatedRiskImpact.riskCondition.impact.value, this.getEndColorTag()]);
		} else {
			//If the Impact is "Leave Alone" then populate impact with the change request impact value
			evaluatedRiskImpact.riskEvaluation.impact = {
				value: this.changeRequestGr.impact + "",
				display_value: this.changeRequestGr.impact.getDisplayValue() + "",
				updated: false
			};
			evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Impact unchanged");
		}

		if (this._log.atLevel(global.GSLog.DEBUG))
			this._log.debug("[calculateRiskConditions] evaluatedRiskImpact: " + JSON.stringify(evaluatedRiskImpact));

		return evaluatedRiskImpact;
	},

 

- Add to ChangeRiskAsmt:

	calculateRisk: function(changeRequestGr) {
		var evaluatedRiskImpact = {};
		changeRequestGr = changeRequestGr || this.changeRequestGr;

		if (!changeRequestGr) {
			evaluatedRiskImpact.errorMsg = gs.getMessage("No valid Change Request record provided");
			return evaluatedRiskImpact;
		}

		var riskAssessment;
		if (this.hasAssessment(changeRequestGr) && this.hasCompletedAssessment(changeRequestGr)) {
			riskAssessment = this._calculateAsmtRisk(changeRequestGr);

			if (this._log.atLevel(global.GSLog.DEBUG))
				this._log.debug("[calculateRisk] riskAssessment: " + JSON.stringify(riskAssessment));
		}

		evaluatedRiskImpact = new RiskCalculator(changeRequestGr).calculateRiskConditions();
		if (!evaluatedRiskImpact.riskEvaluation)
			evaluatedRiskImpact.riskEvaluation = {};

		if (riskAssessment)
			evaluatedRiskImpact.riskAssessment = riskAssessment;

		if (evaluatedRiskImpact.riskCondition) {
			if (this._log.atLevel(global.GSLog.DEBUG))
				this._log.debug("[calculateRisk] evaluatedRiskImpact.riskCondition: " + JSON.stringify(evaluatedRiskImpact.riskCondition));

			if (evaluatedRiskImpact.riskCondition.risk && (evaluatedRiskImpact.riskCondition.risk.value || evaluatedRiskImpact.riskCondition.risk.value === 0) && !isNaN(evaluatedRiskImpact.riskCondition.risk.value))
				evaluatedRiskImpact.riskEvaluation.risk = evaluatedRiskImpact.riskCondition.risk;

			if (evaluatedRiskImpact.riskCondition.impact && (evaluatedRiskImpact.riskCondition.impact.value || evaluatedRiskImpact.riskCondition.impact.value === 0) && !isNaN(evaluatedRiskImpact.riskCondition.impact.value))
				evaluatedRiskImpact.riskEvaluation.impact = evaluatedRiskImpact.riskCondition.impact;
		}

		// Highest risk wins (actually lowest value, High=2, Moderate=3, Low=4)
		if (evaluatedRiskImpact.riskAssessment &&
			evaluatedRiskImpact.riskAssessment.risk &&
			evaluatedRiskImpact.riskAssessment.risk.value && (
				!evaluatedRiskImpact.riskCondition ||
				!evaluatedRiskImpact.riskCondition.risk ||
				!evaluatedRiskImpact.riskCondition.risk.value ||
					parseInt(evaluatedRiskImpact.riskAssessment.risk.value) < parseInt(evaluatedRiskImpact.riskCondition.risk.value)))
			evaluatedRiskImpact.riskEvaluation.risk = evaluatedRiskImpact.riskAssessment.risk;

		if (evaluatedRiskImpact.riskAssessment && evaluatedRiskImpact.riskAssessment.msg)
			gs.addInfoMessage(evaluatedRiskImpact.riskAssessment.msg);

		if (evaluatedRiskImpact.riskCondition && evaluatedRiskImpact.riskCondition.msg)
			gs.addInfoMessage(evaluatedRiskImpact.riskCondition.msg);

		if (!evaluatedRiskImpact.riskCondition && !evaluatedRiskImpact.riskAssessment)
			return evaluatedRiskImpact;

		evaluatedRiskImpact.riskEvaluation.risk.updated = parseInt(evaluatedRiskImpact.riskEvaluation.risk.value) !== parseInt(changeRequestGr.risk + "") || changeRequestGr.risk.changes();

		if (evaluatedRiskImpact.riskEvaluation.risk.updated) {
			evaluatedRiskImpact.riskEvaluation.risk.updatedMsg = gs.getMessage("Risk set to: {0}{1}{2}", [new RiskCalculator().getStartColorTag(), evaluatedRiskImpact.riskEvaluation.risk.display_value, new RiskCalculator().getEndColorTag()]);
			gs.addInfoMessage(evaluatedRiskImpact.riskEvaluation.risk.updatedMsg);
		}

		// Populate legacy values (as customers may have called and expect JSON legacy values)
		evaluatedRiskImpact.risk = evaluatedRiskImpact.riskEvaluation.risk.value;
		evaluatedRiskImpact.riskUpdated = evaluatedRiskImpact.riskEvaluation.risk.updated;
		evaluatedRiskImpact.impact = evaluatedRiskImpact.riskEvaluation.impact.value;
		evaluatedRiskImpact.impactUpdated = evaluatedRiskImpact.riskEvaluation.impact.updated;

		if (this._log.atLevel(global.GSLog.DEBUG))
			this._log.debug("[calculateRisk] evaluatedRiskImpact: " + JSON.stringify(evaluatedRiskImpact));

		return evaluatedRiskImpact;
	},


- If Legacy Change Risk Assessment is active, modify RiskAssessmentCalculator:

	calculateRisk: function(changeRequestGr) {
		// Need to recall initialize if this script is invoked without a GlideRecord
		if (changeRequestGr)
			this.initialize(changeRequestGr);

		var evaluatedRiskImpact = {
			riskAssessment: {},
			riskCondition: {},
			riskEvaluation: {}
		};

		// Evaluate Risk Assessment
		var taskAssessmentGr = new GlideRecord("task_assessment");
		taskAssessmentGr.addQuery("task", this.changeRequestGr.sys_id);
		taskAssessmentGr.query();

		// First Assessment to match wins
		if (taskAssessmentGr.next()) {
			evaluatedRiskImpact.riskAssessment = {
				name: {
					value: taskAssessmentGr.assessment.name + "",
					display_value: taskAssessmentGr.assessment.name.getDisplayValue()
				}
			};
			var masterAssessment = taskAssessmentGr.assessment;
			var instance = taskAssessmentGr.instance;

			if (instance && masterAssessment) {
				var compositeScore = this.calcCompositeScore(instance);
				this.risk = this.getRisk(masterAssessment, compositeScore);
				this.changeRequestGr.risk_value = compositeScore;
				evaluatedRiskImpact.riskAssessment.compositeScore = compositeScore;

				if (!this.risk.value) {
					evaluatedRiskImpact.errorMsg = gs.getMessage("No threshold could be found for Risk Assessment {0}", evaluatedRiskImpact.riskAssessment.name.display_value);
					return evaluatedRiskImpact;
				}
				else {
					evaluatedRiskImpact.riskAssessment.risk = this.risk;
					evaluatedRiskImpact.riskAssessment.msg = gs.getMessage("Risk Assessment calculated: {0}; Risk: {1}{2}{3}", [
							evaluatedRiskImpact.riskAssessment.name.display_value,
							new RiskCalculator().getStartColorTag(),
							evaluatedRiskImpact.riskAssessment.risk.display_value || evaluatedRiskImpact.riskAssessment.risk.value,
							new RiskCalculator().getEndColorTag()
						]);
				}
			}

			if (evaluatedRiskImpact.riskAssessment.msg)
				gs.addInfoMessage(evaluatedRiskImpact.riskAssessment.msg);
		}

		if (this._log.atLevel(global.GSLog.DEBUG))
			this._log.debug("[calculateRisk] evaluatedRiskImpact.riskAssessment: " + JSON.stringify(evaluatedRiskImpact.riskAssessment));

		// Initialize risk
		evaluatedRiskImpact.riskEvaluation.risk = evaluatedRiskImpact.riskAssessment.risk;

		// Evaluate Risk Conditions - impact set, highest risk set based on Assessment vs Conditions
		evaluatedRiskImpact.riskCondition = new RiskCalculator(this.changeRequestGr).calculateRisk().riskCondition;
		if (evaluatedRiskImpact.riskCondition) {

			if (this._log.atLevel(global.GSLog.DEBUG))
				this._log.debug("[calculateRisk] evaluatedRiskImpact.riskCondition: " + JSON.stringify(evaluatedRiskImpact.riskCondition));

			evaluatedRiskImpact.riskCondition.msg = evaluatedRiskImpact.riskCondition.msg ? evaluatedRiskImpact.riskCondition.msg += ": " + gs.getMessage("Risk Condition calculated") : gs.getMessage("Risk Condition calculated");

			if (evaluatedRiskImpact.riskCondition.name && evaluatedRiskImpact.riskCondition.name.value)
				evaluatedRiskImpact.riskCondition.msg += ": " + '' +
					GlideStringUtil.escapeHTML(evaluatedRiskImpact.riskCondition.name.display_value || evaluatedRiskImpact.riskCondition.name.value).replaceAll('"', '"') + "";

			if (evaluatedRiskImpact.riskCondition.risk && evaluatedRiskImpact.riskCondition.risk.value)
				evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Risk: {0}{1}{2}", [new RiskCalculator().getStartColorTag(), evaluatedRiskImpact.riskCondition.risk.display_value || evaluatedRiskImpact.riskCondition.risk.value, new RiskCalculator().getEndColorTag()]);
			else {
				evaluatedRiskImpact.riskCondition.risk = {
					value: this.changeRequestGr.risk.nil() ? "" : this.changeRequestGr.risk + "",
					display_value: this.changeRequestGr.risk.getDisplayValue()
				};
				evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Risk unchanged");
			}

			if (evaluatedRiskImpact.riskCondition.impact && evaluatedRiskImpact.riskCondition.impact.value) {
				evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Impact: {0}{1}{2}", [new RiskCalculator().getStartColorTag(), evaluatedRiskImpact.riskCondition.impact.display_value || evaluatedRiskImpact.riskCondition.impact.value, new RiskCalculator().getEndColorTag()]);
				evaluatedRiskImpact.riskCondition.impact.updated = parseInt(this.changeRequestGr.impact) !== parseInt(evaluatedRiskImpact.riskCondition.impact.value) || this.changeRequestGr.impact.changes();
				if (evaluatedRiskImpact.riskCondition.impact.updated)
					this.changeRequestGr.impact = evaluatedRiskImpact.riskCondition.impact.value;
			} else {
				evaluatedRiskImpact.riskCondition.impact = {
					value: this.changeRequestGr.impact + "",
					display_value: this.changeRequestGr.impact.getDisplayValue(),
					updated: false
				};
				evaluatedRiskImpact.riskCondition.msg += "; " + gs.getMessage("Impact unchanged");
			}

			if (this._log.atLevel(global.GSLog.DEBUG))
				this._log.debug("[calculateRisk] evaluatedRiskImpact.riskCondition: " + JSON.stringify(evaluatedRiskImpact.riskCondition));

			if (evaluatedRiskImpact.riskCondition.impact && (evaluatedRiskImpact.riskCondition.impact.value || evaluatedRiskImpact.riskCondition.impact.value === 0) && !isNaN(evaluatedRiskImpact.riskCondition.impact.value))
				evaluatedRiskImpact.riskEvaluation.impact = evaluatedRiskImpact.riskCondition.impact;

			// Highest risk wins (actually lowest value, High=2, Moderate=3, Low=4)
			if (!evaluatedRiskImpact.riskAssessment.risk.value || (evaluatedRiskImpact.riskCondition.risk.value && parseInt(evaluatedRiskImpact.riskAssessment.risk.value) > parseInt(evaluatedRiskImpact.riskCondition.risk.value)) )
				evaluatedRiskImpact.riskEvaluation.risk = evaluatedRiskImpact.riskCondition.risk;

			gs.addInfoMessage(evaluatedRiskImpact.riskCondition.msg);
		}

		evaluatedRiskImpact.riskEvaluation.risk.updated = parseInt(evaluatedRiskImpact.riskEvaluation.risk.value) !== parseInt(this.changeRequestGr.risk) || this.changeRequestGr.risk.changes();
		if (evaluatedRiskImpact.riskEvaluation.risk.updated) {
			this.changeRequestGr.risk = evaluatedRiskImpact.riskEvaluation.risk.value;
			evaluatedRiskImpact.riskEvaluation.risk.updatedMsg = gs.getMessage("Risk set to: {0}{1}{2}", [new RiskCalculator().getStartColorTag(), evaluatedRiskImpact.riskEvaluation.risk.display_value || evaluatedRiskImpact.riskEvaluation.risk.value, new RiskCalculator().getEndColorTag()]);
			gs.addInfoMessage(evaluatedRiskImpact.riskEvaluation.risk.updatedMsg);
		}

		if (this._log.atLevel(global.GSLog.DEBUG))
			this._log.debug("[calculateRisk] evaluatedRiskImpact: " + JSON.stringify(evaluatedRiskImpact));

		return evaluatedRiskImpact;
	},

 


Related Problem: PRB1353793

Seen In

SR - IRM - Audit Management - New York 2019 Q3
SR - IRM - GRC Profiles - Madrid 2019 Q2
SR - IRM - GRC Workbench - New York 2019 Q3
SR - IRM - Policy and Compliance - Madrid 2019 Q2
SR - IRM - Risk Management - New York 2019 Q3
SR - ITOM - Discovery and Service Mapping - 201908
SR - ITOM - Discovery and Service Mapping - v1.0.35

Fixed In

Madrid Patch 10
New York Patch 5
Orlando
Paris

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-06-09 07:59:59
Published:2020-03-15