Capture Risk Assessment answers and put them into the change work notes?

Conan_Lloyd
Mega Expert

Apparently out compliance folk are not happy that our risk assessments do not version if they are retaken. A solution was proposed to capture the answers when it's taken and add them to the work notes of the change its attached to. Can a kind soul out there help me with the script to do this?

~Conan

1 ACCEPTED SOLUTION

Towards the bottom is how you get the score. The top bit is how you can get answers to specific questions.

Writing a Risk Assessment Answer Back to Change Form Field


View solution in original post

10 REPLIES 10

Conan_Lloyd
Mega Expert

OK, so I still have this issue. I'm unsure of how to catch the answers through a glide record. Would appreciate any help that is out there.


Mlombardo
Kilo Expert

I know it was a while ago, but were you able to get this Conan? I have a similar requirement 🙂


Mlombardo
Kilo Expert

I know it was a while ago, but were you able to get this Conan? I have a similar requirement 🙂


Hi,

I don't believe you can (natively) collect the answers given during a Risk Assessment. This data doesn't get stored to a table anywhere. It's used strictly for the moment in time you generate a risk. It uses the data and compares it to the condition threshold and changes the overall risk. The individual responses are ignored and forgotten at that point.

Below is the UI action OOB that is responsible for generating the risk. As you can see, it's not storing the data anywhere. To change this you'd likely need to create a new table to store your responses in and then modify this UI action (named: Fill Out Risk Assessment) to glide query over to your new table and store the responses.



//create task_assessment record and open risk assessment in popup window

function invokeAssessment(){
var id = g_form.getUniqueValue();
var ga = new GlideAjax('CreateAssessment');
ga.addParam('sysparm_name','checkAssessment');
ga.addParam('sysparm_id',id);
ga.addParam('sysparm_class','change_request');
ga.getXMLWait();
var res = ga.getAnswer();
g_form.hideAllFieldMsgs();
if (res == 'No Condition'){
g_form.addInfoMessage('There are no risk assessments defined for this request');
}
else {
var resArr = [];
resArr = res.split(',', 2);
var taskAsmtID = resArr[0];
var assessmentName = resArr[1];

var d = new GlideOverlay({
title: 'Risk Assessment',
form: 'survey_take'
});
d.setPreference("sysparm_task_assessment", taskAsmtID);
d.setPreference("sysparm_survey", assessmentName);
d.setPreference("sysparm_survey_update", "false");
d.render();

}
}