Accessing Multi-Select Answers and Populating to Embedded Data | XM Community
Skip to main content

I am currently trying to add all selected options from three different multi-select questions into one drop-down question so the user can select which of their selected programs is their primary program of interest. Based on this question (https://www.qualtrics.com/community/discussion/9584/multiple-choice-track-individual-selected-choices-in-piped-text) I learned that this isn't possible to do without JavaScript, so I built out my code, but for some reason, it is not populating to the embedded data fields I set up. I know it's getting the correct data and my for loops are looping through the arrays correctly. Please help!
Qualtrics.SurveyEngine.addOnload(function()
{
var certAll = "${q://QID17/ChoiceGroup/SelectedChoices}";
var mastersAll = "${q://QID15/ChoiceGroup/SelectedChoices}";
var phdAll = "${q://QID19/ChoiceGroup/SelectedChoices}";

var certArr = certAll.split(', ');
var mastersArr = mastersAll.split(', ');
var phdArr = phdAll.split(', ');

for (var i = 0; i < certArr.length; i++) {
switch (i) {
case 0:
Qualtrics.SurveyEngine.setEmbeddedData("${e://Field/Program0}", certArrri]);
break;
case 1:
Qualtrics.SurveyEngine.setEmbeddedData("${e://Field/Program1}", certArrri]);
break;
case 2:
Qualtrics.SurveyEngine.setEmbeddedData("${e://Field/Program2}", certArrri]);
break;
case 3:
Qualtrics.SurveyEngine.setEmbeddedData("${e://Field/Program3}", certArrri]);
break;
}

//two more for loops after this that populate the rest of the Programx fields...

Change

Qualtrics.SurveyEngine.setEmbeddedData("${e://Field/Program3}", certArr[i]);
to
Qualtrics.SurveyEngine.setEmbeddedData("Program3", certArr[i]);


Thank you! I had it this way originally and it wasn't working, but now I know it was because the script can't update embedded data on the question where it will be used.


Leave a Reply