- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2013 08:34 AM
Hi, I am trying to take an answer of Risk Assessment and populate that info back to a field on the Change Form. I found a couple of articles on the wiki that include details on Incident survey results, but can seem to make it work for change and risk assessment.
Thanks in advance for any help you can provide.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2013 11:24 AM
You can modify the '//now iterate the answers' section. Get the sys_id of the question you want to capture the result for, just add a couple of lines after -
var key = arg.substring('QUESTION:'.length);
Assuming that you just want the value of the answer (which is the text of the answer, not the score), something like this might do it.
var key = arg.substring('QUESTION:'.length);
//below is the sys_id of the question you want the answer to
if(key == 'ae168e6b9d40b0c015cb6a9aa0e40572'){
var cr = new GlideRecord('change_request');
cr.get(taskID);
cr.work_notes = value; //update whatever field you want, value is the value of the answer
cr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2013 11:24 AM
You can modify the '//now iterate the answers' section. Get the sys_id of the question you want to capture the result for, just add a couple of lines after -
var key = arg.substring('QUESTION:'.length);
Assuming that you just want the value of the answer (which is the text of the answer, not the score), something like this might do it.
var key = arg.substring('QUESTION:'.length);
//below is the sys_id of the question you want the answer to
if(key == 'ae168e6b9d40b0c015cb6a9aa0e40572'){
var cr = new GlideRecord('change_request');
cr.get(taskID);
cr.work_notes = value; //update whatever field you want, value is the value of the answer
cr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2013 05:20 PM
Jay, you are the man, that worked. The only thing is there is something about the impact field that doesn't let the risk assessment write to that field. I had to create a second choice impact field to make it work. Not sure if it has anything to do with the "Risk Conditions". Anyway, I'm happy with this thanks!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2014 01:46 AM
Hi Jay,
I'm bit confused here
You can modify the '//now iterate the answers' section.
Could you please inform me exactly where(which script include / UI action) I need to make changes to capture the Risk assessment answers to change request form.
Thanks,
Subramanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2015 11:11 PM
This is in the Script Include "SurveyProcessor". In my FUJI instance it's on line 70.
Regards,
Dale.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2020 08:04 AM
Capture Risk Assessment answers and put them into the change work notes?
Yes We Can Do that different way. Here i am get "
answers" Description Filed
Here I Using Background Script to get user response and i am get the Question and Respective user answer i am captured and where i want place that values. "Metric Results"(asmt_metric_result) always stored in this table.
I am Getting Risk Assessment answers using Script include:
var Risk = Class.create();
Risk.prototype = {
initialize: function() {},
testAnswer: function(sys_id) {
var varAnswer = [];
var gr = new GlideRecord("asmt_metric_result");
gr.addQuery("metric.category.nameSTARTSWITHchange^source_id=" + sys_id);
gr.orderBy("metric.order");
gr.query();
while(gr.next()) {
varAnswer.push(gr.string_value.toString());
}
return varAnswer;
},
testQuestion: function(sys_id) {
var varQuestion = [];
var gr = new GlideRecord("asmt_metric_result");
gr.addQuery("metric.category.nameSTARTSWITHchange^source_id=" + sys_id);
gr.orderBy("metric.order");
gr.query();
while (gr.next()) {
varQuestion.push(gr.metric.question.toString());
}
return varQuestion;
},
type: 'Risk'
};
and i am Creating One Business Rule On "Metric Results"(asmt_metric_result) table with Async Rlue and i am Displaying User Response on "Change Table"(change_request) in Description Filed if you can filed
Business Rule :
(function executeRule(current, previous /*null when async*/ ) {
var grChg = new GlideRecord("change_request");
grChg.addQuery("sys_id", current.source_id);
var answer = new Risk().testAnswer(current.source_id);
answer.split(",");
var question = new Risk().testQuestion(current.source_id);
question.split(",");
grChg.query();
if (grChg.next()) {
grChg.description ="**********************USER RESOPNES*******************" + "\n" +
"Question.1 :" + question[0] + "\n" + "Answer :" + answer[0] + "\n" +
"Question.2 :" + question[1] + "\n" + "Answer :" + answer[1] + "\n" +
"Question.3 :" + question[2] + "\n" + "Answer :" + answer[2] + "\n" +
"Question.4 :" + question[3] + "\n" + "Answer :" + answer[3] + "\n" +
"Question.5 :" + question[4] + "\n" + "Answer :" + answer[4];
}
grChg.update();
})(current, previous);
same code you check Background-Script as well .I will Give that Working Code Placed here you can try it :
Background Script :
var answer = new Risk().testAnswer("fc673e932f94a810f7674ae72799b6f9")//Risk Assessment Completed Change Request sys_id
answer.split(",");
var question = new Risk().testQuestion("fc673e932f94a810f7674ae72799b6f9")//Risk Assessment Completed Change Request sys_id
question.split(",");
var gr = new GlideRecord("asmt_metric_result");
gr.addQuery("metric.category.nameSTARTSWITHchange^source_id=fc673e932f94a810f7674ae72799b6f9");//Risk Assessment Completed Change Request sys_id
gr.query();
if(gr.next()){
var grChg= new GlideRecord("change_request");
grChg.addQuery("sys_id",gr.source_id);
grChg.query();
if(grChg.next()){
grChg.description="Question.1 :"+question[0]+"\n"+"Answer :"+ answer[0]+"\n"+
"Question.2 :"+question[1]+"\n"+"Answer :"+ answer[1]+"\n"+
"Question.3 :"+question[2]+"\n"+"Answer :"+ answer[2]+"\n"+
"Question.4 :"+question[3]+"\n"+"Answer :"+ answer[3]+"\n"+
"Question.5 :"+question[4]+"\n"+"Answer :"+ answer[4];
}
grChg.update();
}
Result: