i think you have to move this element after block in survey flow.
Hello @bansalpeeyush29. Sorry for being dense but what do you exactly mean by "move this element after block in survey flow"?
Thanks for looking into my question.
Just to try it out, I switched the order of the embedded variable block and the question block to see if it will make a difference. I get the same error.
!
To add more context in my testing, I reverted the order of the embedded data block and the question block, and I also initialized var1 to 50
!
This scenario proves that I can access the declared and initialized var1 variable (in addOnUnload function), however, it's the call to updating the embedded variable (in addOnload function) that is not working :(
I'm expecting that tmpVar2 would have a value of 100 after the call to Qualtrics.SurveyEngine.setEmbeddedData('var1', '100');
```
Qualtrics.SurveyEngine.addOnload(function()
{
var tmpVar1 = "${e://Field/var1}";
Qualtrics.SurveyEngine.setEmbeddedData('var1', '100');
var tmpVar2 = "${e://Field/var1}";
alert('addOnload:\\ntmpVar1 = ' + tmpVar1 + '\\ntmpVar2 = ' + tmpVar2);
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
var tmpVar = "${e://Field/var1}";
alert('addOnUnload, tmpVar = ' + tmpVar);
});
```
Pop-up alerts generated by code above:
!
!
I found
@TomG's answer https://www.qualtrics.com/community/discussion/comment/15517 to be the answer to my question. When he said "You can't set and pipe an embedded data field on the same page", I checked var1 on a next question block, the variable was indeed updated.