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

Is it possible to set an embedded variable with JS without declaring it first in survey flow?

  • 30 September 2020
  • 1 reply
  • 52 views

Userlevel 2
Badge

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?

icon

Best answer by TomG 30 September 2020, 18:28

View original

1 reply

Userlevel 7
Badge +27

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