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

ArielAriel Community Member Qubie ✭
edited April 27 in Custom Code

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

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

Tagged:

Answers

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭

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

  • ArielAriel Community Member Qubie ✭

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

  • rondevrondev Community Member - Trial User Wizard ✭✭✭✭✭

    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.

  • ArielAriel Community Member Qubie ✭

    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 <b>setting</b> it from the script

Sign In to Comment