In a QX survey we’ve set EmbeddedData to hardcoded value via the Survey Flow UI interface. In the HTML header we’ve included some JavaScript code and in questions we’ve included JavaScript code for trying to getting EmbeddedData into JS code business logic. We debug the JS code in the QX survey preview mode.
The challenge we are facing is that, no matter what QX API/SDK suggestions we found in the docs/community so far we tried, we cannot access EmbeddedData from within JS code:
Can you please try to capture this on ready event?
var seenQTagsED = “${e://Field/seenQuestions}”;
Also, can you make sure that you test this using the proper preview link of the survey so that the JS gets executed??
@Sowrabh1993 Could it be that EmbeddedData cannot be loaded into JavaScript code in preview mode? Probably loading EmbeddedData is possible in “live” mode only...
@thinwybk,
That should not be the case. It works in preview as well. Can you share a snapshot of the code that you have written?
@Sowrabh1993 Does not help in “preview” mode as well. Do I need to “enable” JavaScript APIs via the Qualtrics UI somehow probably?
Same for ExternalDataReference... if I try to get ExternalDataReference into the JS code in “preview” mode it does not work. QX pastes an empty string into the variable instead of the actual value set in the contact list used to define the ExternalDataReference. (According to QX docs the JS code syntax to get ExternalDataReference and EmbeddedData should be exactly the same.)
ExternalDataReference is properly set in Survey Flow:
This is the actual, question specific JS code:
This is what results in “preview” mode (via browser console)… no matter into what QX API method I put the code into:
If I publish the survey (publish button) and try to get the data in “publish mode” it’s the exact same behavior.
If you are pulling anything from contact list, it won’t be pulled in preview mode as the preview is not attached to any contact list respondent.
You can alternatively assign a value to ExternalDataReference embedded data in the survey flow while previewing and then make sure to remove it once preview is done.
Try to hardcode the value to the embedded data in survey flow and then it should pick up the value.
Can you confirm that I cannot get EmbeddedData from header scope JavaScript? At least the builtin IDE seems to raise an issue here.
I’ll try out in question scope JavaScript again.
Finally found out that only a single one of the documented QX API variants works to get EmbeddedData. Works in “preview” mode when hardcoding a value (string).
Hi @thinwybk,
Can you please try to capture this on ready event?
var seenQTagsED = “${e://Field/seenQuestions}”;
Also, can you make sure that you test this using the proper preview link of the survey so that the JS gets executed??
W.r.t. typing this variant is pretty wired cause it might raise “Failed to evaluate page script” issues. See browser debug session above. Personally I’ll not use this one.