How to get total value of survey when survey submitted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2024 09:01 AM
I want to display total value of survey , means if there are values as very low, low ,high , very high, want a total count
Below is the script but not working correctly, Please help!
var test = new GlideRecord('asmt_assessment_instance');
test.addQuery('sys_id','2372c745c3a50210ceb0de1d050131a9');
test.query();
if(test.next()){
gs.print(test.number);
var question = new GlideRecord('asmt_assessment_instance_question');
question.addQuery('instance',test.sys_id);
question.query();
var totalScore = 0;
var questionCount = 0;
// Loop through the questions and calculate the total score
while(question.next()) {
var row = new GlideRecord('asmt_metric_definition');
//define.addQuery('',);
row.addQuery('category','Rockefeller Capital Management Customer Satisfaction Survey');
row.addEncodedQuery('category=8403663297eff110132b37671153aff1^datatype=numericscale',question.metric);
row.query();
if(row.next()){
gs.print('in query count'+ row.getRowCount());
}
/*var response = question.getValue('response'); // Assuming response is the field where the response score is stored
if (response != '') {
totalScore += parseFloat(response);
questionCount++;
}
}
// Calculate the average
var averageScore = totalScore / questionCount;
// Print or use the average score as needed
gs.info('Average score of assessment instance questions: ' + averageScore);*/
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2024 10:07 PM
Hi @Asha Pathak ,
If I get it right you can do like
g_form.getValue("variable_name");
Please Mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak