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

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

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


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


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.


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


Leave a Reply