I have created embedded variables giving a specific text if certain questions are answered with yes. However, I have found that I can only use the embedded variables I create in to the next block (using the piped text $e{field//NameVariable}) but in a same block where the questions are answered I have not been able to.
I have tried to call the embedded variable within the same block is created using javascript with the following code:
Qualtrics.SurveyEngine.addOnload(function(){ var myEmbeddedData = "${e://Field/myEmbeddedData}"; });
or
`Qualtrics.SurveyEngine.addOnload(function(){
let myEmbeddedData = Qualtrics.SurveyEngine.getEmbeddedData("myEmbeddedData").
});`
And then I tried to place in the next query, as piped text, my embbedData like this:
Hi this is your answer ${e://Field/myEmbeddedData}
But when I click on preview, I don’t see the results, just a blank space. Note that if I use this text in the next block, it works.
Thanks in advance!
EDIT:
I am trying to use the following code of javascript in a page after the evaluated questions QID110 and QID111:
var ans = "";
var qid110 = "${q://QID110/ChoiceGroup/SelectedChoices}";
var qid111 = "${q://QID111/ChoiceGroup/SelectedChoices}";
if (qid110 == "Yes" && qid111 == "No") {
ans = "a";
} else if (qid110 == "No" && qid111 == "Yes") {
ans = "b";
} else if (qid110 == "Yes" && qid111 == "Yes") {
ans = "c";
}
Qualtrics.SurveyEngine.setEmbeddedData("test", ans);
in the following page of the javascript I try to pipe the embedded data in the query like this:
This is you answer ${e://Field/test}
But the result is also in blank. So, maybe I am coding wrong. Any help?
2
Answers
This was the code that works for me:
You can’t set and pipe embedded data fields on the same page. If you set the embedded data field using JavaScript (setEmbeddeData()), you can pipe them within the same block as long as they are on a subsequent page.