Multiple value text set embedded data field as multiple choice question | XM Community
Skip to main content

Hi,
Today I was trying to set up a survey where I would like for each of the values of a multiple value text set to be an option in a multiple choice question. So if the embedded data field has 'green, yellow, red' then I would love to be able to ask a participant what their favorite color is and give these three options. I was able to achieve it with Javascript, but I was wondering if there is an easier way. Teaching Javascript to my faculty just to achieve this will be an adventure.
Thank you!
PS, for anyone interested this is my code. I then create a multiple choice question where the values are the embedded data fields that result from this.

Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
   var str = "${e://Field/All%20colors}";
   var res = str.split(", ");
   for (let i = 0; i < str.length; i++) {
      Qualtrics.SurveyEngine.setEmbeddedData("Color " +i, resCi]);
   }
});

Hi there!
If I understand your question correctly, you would like to be able to have the response options for your multiple choice questions be defined by embedded data that is fed into your survey.
If so, this can be executed by taking the following steps:

  1. First, define your embedded data field in the 'Survey Flow' section of your survey. You would need to define a set of new embedded data field according to whatever you'll be passing in (ex. Color1, Color2, Color 3, Color 4). Save your survey flow.

  2. Next, create your multiple choice question. You'll write the question text, then you have the opportunity to define your question response text. For these, you'll need to take two steps: display logic (which may not be applicable to your case) and defining the text itself.

  3. To define display logic: Click on one of the response fields, where it says "Click to write choice 1." When you do, click the blue arrow that appears, and click "Add display logic." Select embedded data field, write your field name (ex. Color1), then select "Is not empty." Doing these for each of your response options ensures they will only present if data is being passed into each response.

  4. To define response text: Click on one of the response fields, where it says "Click to write choice 1." When you do, click the blue arrow that appears, and click "Insert piped text." Select embedded data, then select your field name (Color1). Doing these for each of your response options ensures embedded data is passed into each response option.

Hopefully this answers your question, and is easier to pass on than teaching Javascript! Best of luck- please feel free to respond with any questions :)



Thank you for taking the time to answer!
In step one do you mean that I would have to send all data directly to
'color 1' 'color 2' 'color 3' or would I be able to split up the multivalue text set into those 3 fields?


Hi All,
Just wanted to say thanks for the code here but I spotted a problem in that you have to -1 from the i or else it doesn't include your first instance of the split array. This allowed me to create 10 dynamic fields in a matrix question where I was able to have the name (ie the colour) and then a score against that name. The problem now lies in how you get that into a report as the first field (colour1) may not be the same colour all the time. it could be in a different order.

My solution to this is to make use of textiQ and create topics for all the different colours and use a concatenated embedded field for textiq to use and convert into topics. The scores are words 'very dissatisfied', 'very satisfied' for example which in my preliminary tests seems to work ok.

I call what I've done is a multidimensional dynamic embedded field (which I think is what textiq is to be honest).

If anyone else has solved this problem in a different way I'd be grateful to know the number of acts we have run into 100's meaning I'd have to create 100's of topics which is not ideal!!

here's the final code - there are two fields as we have 2 venues
Qualtrics.SurveyEngine.addOnPageSubmit(function()

{
   var str = "${e://Field/Venue1}";
   var res = str.split(", ");
   for (let i = 0; i < str.length; i++) {
      Qualtrics.SurveyEngine.setEmbeddedData("Venue1Act" +i, res"(i-1)]);
   }
   var str = "${e://Field/Venue2}";
   var res = str.split(", ");
   for (let i = 0; i < str.length; i++) {
      Qualtrics.SurveyEngine.setEmbeddedData("Venue2Act" +i, res((i-1)]);
   }

});
below is what the data looks like in the D&A
image.pngand this is the resulting textiQ once I've built the topic
image.pngThis is the bubble iq widget. This should work for the table iq widget but it's a bit temperamental and I often have to get Qualtrics Support to get it working again


Leave a Reply