We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Automated scripted factor not wokring

rinathombar
Tera Contributor

as per requirement

  • Compliant Status → Effective (value = 1)

  • Non‑Compliant Status → Ineffective (value = 0)

  • Blank Status → Excluded from calculation (not counted in numerator or denominator)

  • Effectiveness Calculation → Average of included statuses

    • If average ≥ 0.5 → Overall suite is Effective

    • If average < 0.5 → Overall suite is Ineffective

 

 

 

try {
var total = 0; // total included controls
var effective = 0; // compliant controls

var gr = new GlideRecord('sn_risk_m2m_risk_control');
gr.addQuery('sn_risk_risk', risk);
gr.query();

while (gr.next()) {
var status = (gr.sn_compliance_control.status || '').toString().toLowerCase();

if (status === 'compliant') {
effective++; // count as 1
total++; // included in denominator
} else if (status === 'non-compliant') {
total++; // count as 0, but included
}
// blank status excluded
}

var score = 1; // default to Ineffective

if (total > 0) {
var effectiveness = effective / total; // average effectiveness

if (effectiveness >= 0.5) {
score = 2; // Effective
} else {
score = 1; // Ineffective
}
}

result.score = score;

} catch (ex) {
result.error = ex.message;
}

 

can you tell me what is issue

0 REPLIES 0