Set Embedded Data | XM Community
Skip to main content
Solved

Set Embedded Data

  • July 29, 2022
  • 5 replies
  • 1958 views

Forum|alt.badge.img+1

Hi - I'm new to Qualtrics and JavaScript. I can't get the simplest code to set embedded data to work. I've seen other posts on the topic, but I'm still stuck.
I created a field called "Field1"
Picture1.png
I created a question with JavaScript to set it's value
Picture2.png
The next question uses Field1

Picture3.png
And when I preview the survey, nothing shows.
Picture4.pngI think I'm doing all the steps in the other examples, but it's not working.
Thanks for any help!!

Best answer by resh_kr

mhv Try this:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
Qualtrics.SurveyEngine.setEmbeddedData("Field1", "Test");
}
});

5 replies

Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • July 29, 2022

mhv Please make sure, you are using the same embedded data inside javascript. Embedded data defined in survey flow is "Field1" and the one which is used inside Javascript is "Field".


Forum|alt.badge.img+1
  • Author
  • July 29, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/48130#Comment_48130Hi resh_kr - Thank you. I did make that change and it still doesn't work (I had made a mistake when creating the post). Any more thoughts? It still doesn't work when the names are all Field1.


Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • Answer
  • July 29, 2022

mhv Try this:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
Qualtrics.SurveyEngine.setEmbeddedData("Field1", "Test");
}
});


Forum|alt.badge.img+1
  • Author
  • July 29, 2022

Hi resh_kr - Thanks again. It still doesn't work. I have that code in the first question, and then in the second question when it tries to display Field1 it still shows nothing. I feel like there is something basic going wrong but I don't know what it is. Is there some configuration or something needed?


Forum|alt.badge.img+1
  • Author
  • July 29, 2022

Ha! I got it to work. I added a page break between the two questions. That must cause it to load and therefore run the code. Sigh.
Thank you!