Use javascript to pull part of drill down selected choices as embedded data | XM Community
Question

Use javascript to pull part of drill down selected choices as embedded data

  • 19 October 2019
  • 3 replies
  • 74 views

Userlevel 1
Badge +3
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

3 replies

Userlevel 7
Badge +27
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.
Userlevel 1
Badge +3
@ 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
Userlevel 1
Badge +3
@ 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