Use a variable as parameter for the embedded data field in setEmbeddedData funtion | XM Community
Solved

Use a variable as parameter for the embedded data field in setEmbeddedData funtion

  • 26 March 2020
  • 3 replies
  • 29 views

Userlevel 4
Badge +16
  • QPN Level 3 ●●●
  • 162 replies
Dear all,

I am using the setEmbeddedData function within a loop. While I can use a variable for the value, it seems I can't use a variable for the embedded data field name.
the parameters look like this at the moment.

Qualtrics.SurveyEngine.setEmbeddedData([ArrayButtonNames[i]],WeekDays[ArrayWeekDaysOrder[i]]);

I've also tried to add the quotes for the embedded data field name but this also hasn't worked.

Does anyone have an idea if this is possible and how it works?


Thanks a lot and best regards

Rudi
icon

Best answer by TomG 26 March 2020, 13:39

View original

3 replies

Userlevel 7
Badge +27
[ArrayButtonNames[i]] isn't a valid variable name. Do you mean ArrayButtonNames[i]?
Userlevel 4
Badge +16
Hi Tom,
yes, thanks for your fast reply. You are correct. This went wrong when writing the question. In the script it was correctly: ArrayButtonNames[i]
Best regards
Rudi
Userlevel 7
Badge +27
As long as the variable is a string you can use a JS variable as an embedded variable name. An issue with dynamically setting embedded variables is that they have to first be defined in the survey flow or they won't be saved in the response data. So, maybe they are getting set, but you aren't finding them if you look in the response data. Have you tried piping them into the subsequent question?

Leave a Reply