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

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

  • October 19, 2019
  • 3 replies
  • 118 views

Forum|alt.badge.img+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

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 19, 2019
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.

Forum|alt.badge.img+3
  • Author
  • October 21, 2019
@ 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

Forum|alt.badge.img+3
  • Author
  • October 21, 2019
@ TomG The code ran when I move it to another question on the next block. Thank you so much for your help. Huong