copying the survey response on the work notes

kunal16
Tera Expert

Hi All,

My requirement is update the work notes of a change request with the survey response (Risk Assessment questionnaire) for the same change. How can this be done?

3 REPLIES 3

Robert Chrystie
ServiceNow Employee
ServiceNow Employee

Hi Kunal,



A much simpler option would be to add the 'Task Assessment > Task' related list onto the Change Request form, so that the responses can be seen from the related list.  



Nevertheless, a Business Rule could be created on the Task Assessment[task_assessment] table to do this.   You would need to start by looking up all of the Survey Responses[survey_response] that are associated with the Survey Instance[survey_instance] for the current Task Assessment.   Once you have those, you can loop through them to capture the question and response for each one, and add that as a Work note to the Task for the current Task Assessment.



Enjoy!


-Robert


Please Provide the script for that

Inactive_Use754
Kilo Expert

You can create a business rule on survey instance table when state is complete.


Script:


var parent_record = new GlideRecord(current.trigger_table);


if(parent_record.get(current.trigger_id)) {


var survey_response = new GlideRecord('asmt_metric_result');


survey_response.addQuery('instance',current.sys_id);


survey_response.orderBy('assign_to_order');


survey_response.query();


var notes = '';


while(survey_response.next()) {


notes = notes + survey_response.instance_question.getDisplayValue() + ' ' + survey_response.string_value + '\n';


}


parent_record.work_notes = notes;


parent_record.update();


}