How do I get the selected answer text of a multiple choice question and set it as an embedded data field | XM Community
Skip to main content

So let’s say I have a multiple choice question with answer choices of 1, 2, 3, 4

 

And I want each of the different answers (as well as null) to be mapped to a embedded data field ‘Answer’ 

Selecting 1 would set Answer = Alpha, 2 would set Answer = Bravo, etc…

What is the easiest way to accomplish this?

this.getSelectedChoices('QID3') supposedly returns an array, how do I pull out the actually selected answer from that array? Feel free to point me at documentation but my google fu is currently too poor to find the correct documentation.

 

Thanks in advance

@hfchen The easiest way is using embedded data block in survey flow with branching condition: https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/embedded-data/#SettingValuesInTheSurveyFlow

If you still want to use JS, use index like normal array.

Qualtrics.SurveyEngine.addOnUnload(function()
{
var selectedChoicesarray = this.getSelectedChoices('QID3');
var selectedChoicesnumber = selectedChoicesarrayr0];
console.log(selectedChoicesarray);
console.log(selectedChoicesnumber);
});

 


I had thought doing if/elseif would be neater looking than having 12 conditions (possibly more in the future) in the survey flow. But I’ve spent enough time on this and I still can’t get the answer to embed into an embedded field so I’ll just go ahead and use conditions for now.

 

Thanks


Leave a Reply