Embedded Data containing Arrays not stored in final DB | XM Community
Skip to main content

Hi all,

I have a question in which I store each change value of a slider in an Array and each time export this array in the same Embedded Data called "p_guesses_x" where x corresponds to the current Loop & Merge round.
What is very weird is that trying to complete the survey this "p_guesses_x" variables only contain one value, instead of being a list, even if more than one value was clicked on the slider.
I tried checking with console.log(list_left) and printing the Embedded Data inside the survey and it seems to work perfectly, the variable being printed with the form "VALUE, VALUE, VALUE,...". However, in the final DB, the list is not there anymore.
Please find an example of the code I am using below.

var list_left =  ];
var round = "${lm://CurrentLoopNumber}";


 document.getElementById("topleftSlider").onchange = function() {
    getValuetopleft();
jQuery("#NextButton").show();
 };

function getValuetopleft() {
   var val = document.getElementById("topleftSlider").value //get the oninput value
   list_left.push(val)
   Qualtrics.SurveyEngine.setEmbeddedData('p_guesses_' + round, list_left)
}
What could be the cause of this weird behavior? Thanks a lot for your replies and help :)

You can't store an JS array as an embedded data field. You have to stringify it somehow. Try this:
Qualtrics.SurveyEngine.setEmbeddedData('p_guesses_' + round, list_left.join(","));


https://community.qualtrics.com/XMcommunity/discussion/comment/45024#Comment_45024This actually did not work for some reason, but doing the same with list_left.join() worked (although they should be equivalent in this case..).

Thanks TomG !


Leave a Reply