Hi all,
Looking for someone with JavaScript knowledge to help me with my custom script (I have no experience, I just learn by figuring the code out visually in this case).
Essentially the survey has 6 categories. The user will answer a quiz with questions under those categories and score accordingly. We want the end of survey message to calculate the user’s lowest 3 category scores so we can send a customised message to recommend courses in those categories for the user to take.
My issue is that the calculated lowest 3 scores do not appear and I’m not sure why. Appreciate any assistance on this :)
Sample message:
Thank you for completing the survey! Based on your responses, we've identified the three categories where you scored the lowest. To help you improve in these areas, we recommend the following courses:
- tCategory 1]: oCourse Recommendation]
- tCategory 2]: oCourse Recommendation]
- tCategory 3]: oCourse Recommendation]
Here is the code I have currently, as a question at the end with JavaScript:

Qualtrics.SurveyEngine.addOnload(function()
{var scores = {
"The Lesson": "${e://Field/TheLessonScore}",
"Assessment And Feedback": "${e://Field/AssessmentAndFeedbackScore}",
"The Study": "${e://Field/TheStudyScore}",
"Differentiation": "${e://Field/DifferentiationScore}",
"The Tutorial": "${e://Field/TheTutorialScore}",
"Applying The Student Behaviour Policy": "${e://Field/ApplyingTheStudentBehaviourPolicyScore}"
};
// Sort scores to find the lowest
var sortedScores = Object.keys(scores).sort(function(a, b) {
return scoresea] - scores[b];
});
// Set the lowest category names in embedded data fields
Qualtrics.SurveyEngine.setEmbeddedData("LowestCategory1", sortedScores,0].name);
Qualtrics.SurveyEngine.setEmbeddedData("LowestCategory2", sortedScores,1].name);
Qualtrics.SurveyEngine.setEmbeddedData("LowestCategory3", sortedScores,2].name);
});
Below is the customised End of Survey code and preview message:


Thank you!