JS set variable as 1 or 0 as embeddedData | XM Community
Skip to main content
Question

JS set variable as 1 or 0 as embeddedData

  • 6 August 2019
  • 1 reply
  • 1 view

Why can I not say,



if (Value > val) {

var correctchoice = 1;

} else {

var correctchoice = 0;

}

Qualtrics.SurveyEngine.setEmbeddedData("Correctchoice ", correctchoice);



or



if (Value > val) {

var correctchoice = "1";

} else {

var correctchoice = "0";

}

Qualtrics.SurveyEngine.setEmbeddedData("Correctchoice ", correctchoice);



whereas this works?



if (Value > val) {

var Pruefung = "Take it";

} else {

var Pruefung = "Don't take it";

}

Qualtrics.SurveyEngine.setEmbeddedData("Pruefung", Pruefung);
Just a couple of things: Are you trying to use correctchoice on the same page you set it? I had a post TomG answered alerting me that's not possible (https://qualtrics.com/community/discussion/5171/setembeddeddata-not-writing-back-to-qualtrics#latest). Also, did you define correctchoice in the SurveyFlow? You don't have to hardcode in a value, but you need to declare it in order to use it in your survey.



Those 2 things being stated, the fact that your Pruefung example works means the problem isn't with the logic in your code. According to the API documentation, setEmbeddedData takes a string, so your first code block would fail as your trying to pass it an int.



I hope something I said helps spark an idea, best of luck!

-Jeremy

Leave a Reply