- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2014 12:34 PM
I have found alot of talk around this issue, but haven't found anything specific on this. My group wants to have the result of the Risk Assessment (the raw score value) tracked on the CHANGE REQUEST so that they can do some statistical analysis on it over the long term.
My problem is that I can't find how to get to that Risk Score. I can see within the Risk Calculator scripts where the system is running a query against the Risk Assessment, but I don't see anywhere where there is a way (other than that query model) to get that value from the completed Risk Assessment, and then populate it in the Change Request form.
Any assistance on this would be really helpful. Thanks!
Chris O'Neill
CAI
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2014 01:02 PM
Hi Chris,
I did some digging and it doesn't look like that score is actually captured anywhere. If you wanted it on your change request you could add a new field and then put something like this in a before update business rule. Adding to a new business rule let's you have this functionality without updating any OOB functionality.
var score = 0;
var srGR = new GlideRecord('survey_response');
srGR.addQuery('instance.task', current.sys_id);
srGR.addNotNullQuery('answer_integer');
srGR.query();
while (srGR.next()){
score += srGR.answer_integer;
}
current.u_my_new_score_integer_field = score;
I grabbed most of that code from the calcCompositeScore() function in the RiskAssessmentCalculator script include.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2014 01:10 PM
Glad you got this working! Could you mark my answer correct if it worked for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2015 05:33 AM
Hi, thanks for this, this has helped me alot, but, the only problem I have is that its adding up all the scores from the assessment regardless of whether or not its related to the assessment on the problem record (we are using the risk assessment on Problem to calculate a Defect Risk) A new risk assessment has been set up called Defect Prioritisation Calculation
I've got a business rule to run this. I added in a check in the log, and the instance brings back all instances where a survey has been completed:
gs.log('im going to run the score');
gs.log('my current sys ID is - ' +current.sys_id);
var score = 0;
var srGR = new GlideRecord('survey_response');
srGR.addQuery('instance.task', current.sys_id);
srGR.addNotNullQuery('answer_integer');
srGR.query();
while (srGR.next()){
gs.log('my answer interger is - ' +srGR.answer_integer);
gs.log('instance is - ' +srGR.instance);
score += srGR.answer_integer;
}
current.u_dpc = score;
current.update();
When I try to manually get to the survey responses for a particular problem, I can not see instance.task in the list. ( I have attached a screen shot)
Any ideas how I get round this so I only get the scores related to the current problem record?
Any help is appreciated
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2019 07:42 AM
Note for future adventurers. If you are using the new assessment functionality...I couldn't get the risk_value to calculate anymore. Maybe there is a secret sys_properties to enable that.
I added this code to the "Calculate Risk" UI action to calculate the risk value. There are probably better ways to do this of course, but this worked for me.
//Calculate Risk Value
var score = 0;
var gr = new GlideRecord('asmt_assessment_instance_question');
gr.addQuery('instance.task_id', current.sys_id);
gr.query();
while (gr.next()){
score += parseInt(gr.getValue('value'));
}
current.risk_value = score;
current.update();