Use javascript to pull part of drill down selected choices as embedded data | XM Community
Skip to main content
Hi,

I have a drill down question that I would like to pull out part of the selected choices as embed data. I tried this but it does not work:

var origin = "${q://QID3/ChoiceGroup/SelectedAnswers/1}".substring(0, 4);

var destination = "${q://QID3/ChoiceGroup/SelectedAnswers/2}".substring(0, 4);

Qualtrics.SurveyEngine.setEmbeddedData("origincode", origin);

Qualtrics.SurveyEngine.setEmbeddedData("destinationcode", destination);

I knew very little about Javascript and could not figure out why this does not work.

Thank you very much.

Huong
Does this JavaScript run on the same page as the drill-down question? The piped fields won't be populated until you go to the next page.
@ TomG

Thank your for your prompt response. I put this Script on addOnUnload() of the same drill-down question, thinking that it is when the page is left. However, it does work. Can you help.

Thanks so much!

Huong
@ TomG

The code ran when I move it to another question on the next block.

Thank you so much for your help.

Huong

Leave a Reply