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

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

  • September 30, 2020
  • 1 reply
  • 64 views

Forum|alt.badge.img

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?

Best answer by TomG

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.

1 reply

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • September 30, 2020

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.