Hi Qualtrics community,
I currently have two functions set up in a survey which aim store and retrieve some embedded data as part of a for loop. Storing the data works fine, but retrieving it does not. Here some simplified snippets:
Setting the embedded data (works fine)
x = ['my','data','here'];
x.forEach((element, index) => {
if(element) {
//set element as embedded data (please note I am starting from 1, not 0)
Qualtrics.SurveyEngine.setEmbeddedData( 'My_Data' + (index+1), element);
}
console.log("${e://Field/My_Data2"); // => 'data'
Getting the embedded data (does not work)
//getting the embedded data (does not work)
for (let i = 1; i <= 3; i++) {
var embed = "${e://Field/My_Data" + i + "}" //never works
if(embed)
console.log("found " + embed) //this never runs because 'embed' is always empty
}
Strangely, if I set
embedto a static value like
"${e://Field/My_Data2}", it works just fine and outputs the expected value.
Why would this be the case? As far as I can tell in this case,
embedshould resolve the same whether it is defined statically or programatically.
Thank you in advance for any insights!