How can I pipe the first answer choice displayed from a previous question? | XM Community
Skip to main content

Let’s say Q1 choices are A, B, C, and D and they are displayed in randomized order. How can I pipe the first choice that appeared in Q1 to the next question?

There is no direct way to pipe the first choice of the previous question to the next. But with the help of JS we can doo this.


Hi,

Add this code to your question’s custom javascript:

Qualtrics.SurveyEngine.addOnReady(function () {

function getChoiceTextByKey(input, key = 'x') {
if (
input &&
typeof input === 'object' &&
input.Choices &&
input.Choicesekey] &&
typeof input.Choicesekey].Text === 'string'
) {
return input.Choicesekey].Text;
}
return null;
}

const question = this.getQuestionInfo();
const displayedFirst = getChoiceTextByKey(question, this.getChoices()(0]);
Qualtrics.SurveyEngine.setJSEmbeddedData('displayedFirst', displayedFirst);

});

 

With the ED “__js_displayedFirst” at the beginning of your survey flow:

 

Pipe in the value of that ED in subsequent questions with “${e://Field/__js_displayedFirst}”


Leave a Reply


OSZAR »