Refer to previous answer with shortlist | XM Community
Skip to main content

Hi community,
I have in other softwares been able to create a list that mirrors the answers from a question, but with a shorter text-version. When I pipe in the answer from a previous question, I can pipe in a shorter text than the original answer. I have not figured out a system for this in Qualtrics. Help please 🙂!
Best, Lise

What do you mean by "shorter text version"? Could you please share an example or link.


Here is an example:
Q1 - Choose what activity you like the best:

  1. Climbing (text text text text)

  2. Soccer (text text text text)

  3. Swimming (text text text text)

  4. Other;

Say I answered swimming i Q1. I would like to reference the answer, but leave out (text text text text)
Q2 - What about swimming is it that you like the most?
Previously I have created a custom list that basically says IF you answered "Swimming (text text text text)" then the value for your new list is "Swimming". But any solution that creates the same result will do : )
Thanks in advance 🙂
Lise


You can do this either using branch logic or JS. In either case you'll need to create an embedded data field, and your final question will look something on the lines of
What about "${e://Field/activity_chosen}" is it that you like the most?
With branch logic in the survey flow, you set your embedded variable

activity_chosen 
to be equal to whatever you want based on the choice made by the people.
If you would like to use JS, the following code should do the job:
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
    
    const qid = this.questionId;
    const cid = this.getChoiceValue();
    choice_text = document.querySelector("#"+ qid + "-" + cid + "-label").innerText;
   
    // Splitting based on a space, you can do it for any other character that you choose
// "Mountain-Climbing" will work. "Mountain Climbing" will result in "Mountain"
    choice_text = choice_text.split(" ");    
    Qualtrics.SurveyEngine.setEmbeddedData("activity_chosen", choice_text_0]);

// The code below is only required if you have a requirement for spaces in your short text
// You'll need to go to recode values and change the variable names to the desired short text
// If this is not required, then delete from here

Qualtrics.SurveyEngine.setEmbeddedData("activity_chosen", this.getChoiceVariableName(cid));

//Delete till here. It won't work if you don't change variable names and don't delete..


});


Leave a Reply