Risk Assessment Business Rule to change form values

Community Alums
Not applicable

I have a Risk Assessment set up in the Change module.  Based on one of the question's answer/value of service impact from the Risk Assessment, we would like to populate the Impact value on the change form.  I have created a business rule that runs on insert and update: 

(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var chg = current.task_id.getRefRecord();
chg.u_risk_assessment_complete = true;

var gr = new GlideRecord('asmt_assessment_instance_question');
gr.addQuery('source_id', chg.sys_id);
gr.addNotNullQuery('source_id');
gr.addQuery('metric', 'ee4880a1dbe9b3c0deca467239961957');
gr.query();
while(gr.next()) {
gs.log('The CHG0031870 Instance is ' +gr.instance);
gs.log('The CHG0031870 Value is ' +gr.value);
if (gr.value == 1) {
chg.impact = 0; // impact value of none
}
if (gr.value == 2) {
chg.impact = 3; // impact value of low
}
if (gr.value == 3) {
chg.impact = 2; // impact value of medium
}
if (gr.value == 4) {
chg.impact = 1; // impact value of high
}
if (gr.value == 5) {
chg.impact = 1; // impact value of high
}
}

chg.update();

})(current, previous);

 

Above we are taking the current assessment and pulling the sys_id of the service impact question and the value from that question.  Then we have mapping to what the change form should display in the Impact field.  We also mark the risk assessment as complete to trigger other logic in the background.  

The problem we are encountering is that when a user makes a mistake or wants to edit the risk assessment, a new assessment instance is created.  This causes the business rule to miss the logic to fire and no update occurs when the service impact question in the risk assessment is changed.  The value on the change form Impact field does not automatically change to desired value.  How can we get the servicenow instance to only operate off of one assessment instance per change?  Or how can I alter my business rule to know which assessment instance should be looked at based on the current change request?

 

Thanks in advance!

5 REPLIES 5

@Community Alums - Were you able to come up with a working solution? If yes, would you please share? I need to identify a solution for the same requirement. Thanks!