How to export embedded data stored with JS? | XM Community
Skip to main content
Solved

How to export embedded data stored with JS?

  • July 2, 2020
  • 4 replies
  • 245 views

Forum|alt.badge.img

I'm using JS to store embedded data (code below). It seems to work, as I am able to embed the data in the survey. However, when I export the survey responses the embedded data variable is empty. I created a variable in the survey flow before the JS code was applied (attached as an image), but it still doesn't work. Any idea what I'm doing wrong?
Here is the code:

Qualtrics.SurveyEngine.addOnload(function()
{
jQuery('.QuestionOuter').css('display','none')
var firstName = "${e://Field/firstName}";
});
Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery('input[type="checkbox"]').prop('checked',true);
var qid= this.questionId;
Qualtrics.SurveyEngine.setEmbeddedData('firstName',String(jQuery('#'+qid).find('.Selection').eq(0).text()));
jQuery('#NextButton').click();
});

Here is how I created the embedded data variable:
Screen Shot 2020-07-01 at 8.43.42 PM.png

Best answer by rondev

https://www.qualtrics.com/community/discussion/comment/27472#Comment_27472Okay, so java script does not work when generating test responses.

4 replies

Forum|alt.badge.img
  • Author
  • July 2, 2020

Strange - looks like it wasn't working when I used qualtrics' generated responses. However, when I responded myself it did record the randomization.


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • July 2, 2020

https://www.qualtrics.com/community/discussion/comment/27472#Comment_27472Okay, so java script does not work when generating test responses.


SurajK
QPN Level 3 ●●●
Forum|alt.badge.img+4
  • QPN Level 3 ●●●
  • July 2, 2020

The script doesn't have any issue LOB , if you want to check the embedded data value in the middle of testing/in the link you can check in console, use the below code to check if the correct data is getting stored in embedded data.
Qualtrics.SurveyEngine.getEmbeddedData('firstName')
image.png


  • September 20, 2021

So there is no way that I can record the embeddedData from a JS code with test responses? I would need to do that to test if my JS code works, e.g. if it randomizes correctly. I understand that I can use the console and that I could enter my own responses (then it is recorded), or test the JS separately and independent from Qualtrics, but this is not what I need. Any ideas?