Automated scripted factor not wokring
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
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
