Use a variable as parameter for the embedded data field in setEmbeddedData funtion | XM Community
Skip to main content
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
[ArrayButtonNames[i]] isn't a valid variable name. Do you mean ArrayButtonNames[i]?
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
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