Why my embbeded variable not show up inmediatly? | XM Community
Skip to main content

Hi

 

I just created an embbeded variable during the response of question A with the following code

Qualtrics.SurveyEngine.addOnPageSubmit(function() {

var x = "${q://QID1007/ChoiceGroup/SelectedAnswers/26}";

var ans="During the time we just identified, " + x + "]";  

Qualtrics.SurveyEngine.setEmbeddedData("Timing", ans);


});

And I piped in the embbeded variable in the next question B

${e://Field/Timing}, did you do other stuffs?

So, what I got is only “During the time we just identified “ without the response in question A, but if go back using the button to question A and return with the next button to question B, it appears!

 

So, why is this happening and how I can show inmediatly my embbeded variable in question B when people responded question A?

 

Thank you!

Hi @Josang,
Just write this in question B:
During the time we just identified, ${q://QID1007/ChoiceGroup/SelectedAnswers/26}, did you do other stuffs?

Why do you need the Embedded Data


It sounds like QID1007 is question A.  You can’t pipe the answer to a question on the same page as the question. The pipes are resolved before the page is sent to the browser. You would have to get the selected answers using the JS API or directly from the DOM.

The easiest solution is the one provided by @dxconnamnguyen.

 

 


Thank you all for your replies, some clarifications:

 

1.- I can’t piped  ${q://QID1007/ChoiceGroup/SelectedAnswers/26} in question B because if the person responded other questions before with yes, the value of timing change to something completly different. So I need to get the value here if people get this branch of the survey.

 

2.- I don´t want to piped the selected choice in the same page/question. I want the response of the question A and piped the choice in a next question B. I was able to do it in another scenarios coditioned certain responses, but now here I am using direclty the response got it, but it doesn´t works.

 

If you have any other suggestion. Please, let me know.

 

Thanks!  

 


@Josang So you want to save it to use later, am I right?
If piping the answer got messed up, try make it a condition

var x = "${q://QID1007/ChoiceGroup/SelectedAnswers/26}";

if(x=="aaaa"){var ans="During the time we just identified, aaaa";}
if(x=="bbbb"){var ans="During the time we just identified, bbbb";}

Let me know if it work


@dxconnamnguyen Thank you very much for your response. This way works, in fact it is the same one I used when I used multiple choice questions (Yes/No). But in this case, my question (drill drop down type) has many choices (100+) and, although I thought about that solution too, I didn't want to create many lines of code. Also, since it is a time question, if this survey is implemented in the next or subsequent year the categories should change and, therefore, the code. This would imply a heavy workload that I think, if only the value of the answer to the question was obtained, should be enough to works in any time context.  

If you have an idea how to get the description of the selected option from JS, and then store it in an embedded variable that would be great. I understand that I can't do it from the question because Qualtrics doesn't save the answer to question A "${q://QID1007/ChoiceGroup/SelectedAnswers/26}" until I hit "next". If there is no way, maybe I have to create separate block for question A and B and use survey flow to create the embedded variable, so I can use it immediately to the next question B.   

 

Best,

JA


@Josang Your case is more complicated than I assumsed.
I think @TomG here will have a hint to solve this, he’s like a wizard with this thing.


@Josang,

Is A (QID1007) the drill down?


@TomG 

Hey TomG, yes QID1007 is a drill down question.

 

Thanks in advance for any insight!

Best.


Leave a Reply