Is it possible to set an embedded variable with JS without declaring it first in survey flow? | XM Community
Skip to main content

I am using a loop & merge with over 100 loops. I would like to make a new variable to capture the order the question appears in for each of the loops. Generally this takes the form of:

// current decision number
var decision = "${e://Field/decision}"
var decision = parseInt(decision);

// the current decision number is the same as the order of the questions
var questionText = "${lm://Field/1}"
Qualtrics.SurveyEngine.setEmbeddedData(questionText + "_order", decision);


// setup decision number for next loop
var decision = decision + 1;
Qualtrics.SurveyEngine.setEmbeddedData("decision", decision);

With the

questionText + "_order"
becoming a new variable for each loop. Is there any workaround for not declaring the 100+ variables in my survey flow?

If you want the variables saved in the response data, they have to be declared in the survey flow. You can programmatically create the variables with a web service.


Leave a Reply