Any idea why Qualtrics.SurveyEngine.setEmbeddedData doesn't work? | Experience Community
Skip to main content
Question

Any idea why Qualtrics.SurveyEngine.setEmbeddedData doesn't work?

  • Apr 27, 2020 12:12 PM UTC
  • 4 replies
  • 144 views

Hi all,

I'm trying to set an embedded data in the Qualtrics.SurveyEngine.addOnPageSubmit function, but it doesn't work (no error message, only that the embedded data doesn't get the assigned value)
This is the code
Qualtrics.SurveyEngine.addOnPageSubmit(function() 
{
   var q2= this.getChoiceAnswerValue();
  Qualtrics.SurveyEngine.setEmbeddedData("Player1Tokens",q2);
alert('You gave Player 1 '+ q2 + ' tokens');
alert('They have now ' + "${e://Field/Player1Tokens}" + ' tokens');
});
(From the alert I know that q2 gets the right value; still, Player1Tokens doesn't get the q2 value)
FYI - the Player1Tokens embedded data is initiated in the survey flow before any block is displayed to users

4 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Apr 27, 2020 12:15 PM UTC

Have you declared "Player1Tokens" embedded data in survey flow before the question where you are using this JS?


  • Author
  • Apr 27, 2020 12:45 PM UTC

Thanks, rondev. Yes, the embedded data is assigned in the survey flow before any block is displayed to users


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Apr 27, 2020 12:51 PM UTC

Can you try piping - ${e://Field/Player1Tokens} in the following questions, If it is displayed over their, make sure there is page break between question.


  • Author
  • Apr 27, 2020 2:57 PM UTC

Thanks, rondey. The weird thing is that this embedded data field Player1Tokens is recognized from the function (see that the following line works perfectly:
alert('They have now ' + "${e://Field/Player1Tokens}" + ' tokens');
So the problem is with setting it from the script