Risk Condition advanced condition answer variable is not populated with the result of the script evaluation if answer is not on the last lineDescriptionRisk Condition advanced condition answer variable is not populated with the result of the script evaluation if answer is not on the last line and is always false.Steps to Reproduce 1) Navigate to Risk Conditions 2) Create a new Risk Condition with Use advanced condition ticked 3) Set Risk level to High and Order field to 1 4) In the advanced condition script field put answer = true; gs.info("answer is: " + answer); 5) Create a change and run risk calculation Actual Result: Risk is set to low as the Default Risk condition is used Expected Result: Risk is set to High WorkaroundPaste the following function into the script include RiskCalculator _evaluateRiskConditions: function() { var evaluatedRiskImpact = { riskCondition: { active: false, match: false } }; var evaluator; var riskConditionGr = this._getRiskConditionsGr(); // First risk condition to match wins while (riskConditionGr.next() && !evaluatedRiskImpact.riskCondition.match) { evaluatedRiskImpact.riskCondition.active = true; if (riskConditionGr.use_advanced_condition) { if (!evaluator) { evaluator = new GlideScopedEvaluator(); evaluator.putVariable("current", this.changeRequestGr); evaluator.putVariable("answer", false); } evaluator.evaluateScript(riskConditionGr, "advanced_condition"); evaluatedRiskImpact.riskCondition.match = evaluator.getVariable("answer"); } else evaluatedRiskImpact.riskCondition.match = GlideFilter.checkRecord(this.changeRequestGr, riskConditionGr.condition); if (evaluatedRiskImpact.riskCondition.match) { evaluatedRiskImpact.riskCondition.sys_id = riskConditionGr.getUniqueValue(); evaluatedRiskImpact.riskCondition.name = { value: riskConditionGr.getValue("name") || "", display_value: riskConditionGr.name.getDisplayValue() || "" }; evaluatedRiskImpact.riskCondition.order = { value: riskConditionGr.getValue("order") || "", display_value: riskConditionGr.order.getDisplayValue() || "" }; evaluatedRiskImpact.riskCondition.description = { value: riskConditionGr.getValue("description") || "", display_value: riskConditionGr.description.getDisplayValue() || "" }; evaluatedRiskImpact.riskCondition.useScriptValues = { value: riskConditionGr.getValue("use_script_values") || "", display_value: riskConditionGr.use_script_values.getDisplayValue() || "" }; if (riskConditionGr.use_script_values) { if (!evaluator) { evaluator = new GlideScopedEvaluator(); evaluator.putVariable("current", this.changeRequestGr); } evaluator.evaluateScript(riskConditionGr, "script_values"); evaluatedRiskImpact.riskCondition.risk = { value: this.changeRequestGr.risk.nil() ? "" : this.changeRequestGr.getValue("risk") || "", display_value: this.changeRequestGr.risk.getDisplayValue() || "" }; evaluatedRiskImpact.riskCondition.impact = { value: this.changeRequestGr.impact.nil() ? "" : this.changeRequestGr.getValue("impact") || "", display_value: this.changeRequestGr.impact.getDisplayValue() || "" }; } else { evaluatedRiskImpact.riskCondition.risk = { value: riskConditionGr.getValue("risk") || "", display_value: riskConditionGr.risk.getDisplayValue() || "" }; evaluatedRiskImpact.riskCondition.impact = { value: riskConditionGr.getValue("impact") || "", display_value: riskConditionGr.impact.getDisplayValue() || "" }; } this._setRiskCondition(evaluatedRiskImpact.riskCondition.sys_id, evaluatedRiskImpact.riskCondition.risk.value, evaluatedRiskImpact.riskCondition.impact.value); this._setChangeRiskDetails("risk_condition_has_run", true, this.changeRequestGr); // Populate legacy values (as customers may have called and expect JSON legacy values) evaluatedRiskImpact.hasValue = evaluatedRiskImpact.riskCondition.match; evaluatedRiskImpact.name = evaluatedRiskImpact.riskCondition.name.value || ""; evaluatedRiskImpact.order = evaluatedRiskImpact.riskCondition.order.value || 0; evaluatedRiskImpact.description = evaluatedRiskImpact.riskCondition.description.value || ""; evaluatedRiskImpact.impact = evaluatedRiskImpact.riskCondition.impact.value || ""; evaluatedRiskImpact.impactLabel = evaluatedRiskImpact.riskCondition.impact.display_value || ""; evaluatedRiskImpact.risk = evaluatedRiskImpact.riskCondition.risk.value || ""; evaluatedRiskImpact.label = evaluatedRiskImpact.riskCondition.risk.display_value || ""; // End of legacy values } } if (evaluatedRiskImpact.riskCondition.active && !evaluatedRiskImpact.riskCondition.match && !this._dryRun) { evaluatedRiskImpact.riskCondition.msg = gs.getMessage("No matching Risk Conditions - Risk and Impact unchanged"); this._clearRiskCondition(); } else if (!evaluatedRiskImpact.riskCondition.active) { evaluatedRiskImpact.riskCondition.msg = gs.getMessage("No active Risk Conditions - Risk and Impact unchanged"); this._clearRiskCondition(); } if (this._log.atLevel(global.GSLog.DEBUG)) this._log.debug("[_evaluateRiskConditions] evaluatedRiskImpact: " + JSON.stringify(evaluatedRiskImpact)); return evaluatedRiskImpact; }, Related Problem: PRB1482765