How do you get the Embedded Data from coded questions to populate a follow up survey? | XM Community
Skip to main content

Hi XM Pros!
I have spend 3 days trying to figure this out. I have used the Qualtrics tool nearly 5 years now and know most of the functionality. Despite this, myself and our team, our Qualtrics account manager and their technical support team are unable to identify a working solution!
Any help would be greatly appreciated. In summary, some survey data needs to be automatically populated into a follow up survey, to support a significant NHS project.
Thanks in advance,
Tom
Lead User Researcher, NHS Digital


Goal:
To repopulate questions with their previous responses (single radio buttons, check boxes) using Embedded Data from with the directory.
What works:
Saving responses to directory
User personalised urls and authentication
Populating text responses; this done by setting 'Default' response to the embedded data value

Problems:
1 - User Data saved into the Directory of the type (Radio Button or Check Box) cannot easily be repopulated into the follow-up questions.
2 - Using the Q Autopopulate tool returns incorrect values. Q populate selects the original (system-level) code when the survey was created. It is likely to be be incorrect as any modifications to the ordering or number of options have been made after initial survey publication. Using re-code values does not work either, as it still selects the underlying code for items (the system codes cannot be changed).
Note - Qualtrics have confirmed this problem and that there is no resolution planned.
3 - Further issue with Q Populate. By saving 'Recoded Values' as Embedded Data, When it is retrieved using autopopulate it does not create the query string correctly. The recoded values include spaces such as "1, 2, 3". The spaces are also added to the string which cause it to fail. When applying "?format=urlencode" it still fails
4 - The Javascript implementation is unclear, I've followed the suggestions provided in many other posts but none provided a successful workaround.


Sources read and tested - it does not work
Embedded data
https://www.qualtrics.com/support/iq-directory/directory-contacts-tab/directory-options/#EmbeddedData
Query strings:
https://www.qualtrics.com/support/vocalize/dashboard-settings-cx/dashboard-data/recoding-values/
https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/passing-information-through-query-strings/#PassingInformationIntoASurvey
https://community.qualtrics.com/XMcommunity/discussion/9680/pulling-embedded-data-into-redirected-survey-using-query-strings
https://community.qualtrics.com/XMcommunity/discussion/7724/how-do-you-code-multi-word-embedded-data-to-auto-populate-into-another-survey
https://community.qualtrics.com/XMcommunity/discussion/comment/24713#Comment_24713
https://www.qualtrics.com/support/survey-platform/common-use-cases-rc/pulling-data-into-a-second-survey-longitudinal-surveys/

Q populate:
https://community.qualtrics.com/XMcommunity/discussion/5090/q-populateresponse-queries
https://community.qualtrics.com/XMcommunity/discussion/comment/18271#Comment_18271 Generating Test Responses with Q_PopulateResponse
https://www.qualtrics.com/support/survey-platform/survey-module/survey-flow/standard-elements/passing-information-through-query-strings/#HowToQ_PopulateResponse

Recoding values:
https://www.qualtrics.com/support/vocalize/dashboard-settings-cx/dashboard-data/recoding-values/
https://community.qualtrics.com/XMcommunity/discussion/13816/recode-values-and-scales-dont-match

Replace spaces in url / embedded data
https://community.qualtrics.com/XMcommunity/discussion/comment/45386#Comment_45386
https://community.qualtrics.com/XMcommunity/discussion/12016/how-can-i-strip-the-first-7-8-characters-of-a-text-entry-off-of-the-response

url encoder https://www.urlencoder.org/
https://permadi.com/tutorial/urlEncoding/
?format=urlencode

Javascript:
https://community.qualtrics.com/XMcommunity/discussion/20562/how-to-pull-selected-choices-into-javascript
https://community.qualtrics.com/XMcommunity/discussion/4261/prior-year-s-responses-prepopulated-for-the-current-year-s-survey
https://community.qualtrics.com/XMcommunity/discussion/19233/autofill-the-answer-of-a-question-based-on-answer-of-previous-question
https://community.qualtrics.com/XMcommunity/discussion/941/javascript-default-choices-on-multiple-dropdown-answers-in-matrix-table
https://community.qualtrics.com/XMcommunity/discussion/comment/18568#Comment_18568
https://community.qualtrics.com/XMcommunity/discussion/494/how-can-i-trim-spaces-from-a-text-response

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var input = jQuery("#"+this.questionId+" .InputText");
input.val(input.val().replace(/^https?:\\/\\//i,""));
});

Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var input = jQuery("#"+this.questionId+" .InputText");
input.val(input.val().replace(/, /g,''));
});
https://community.qualtrics.com/XMcommunity/discussion/comment/45053#Comment_45053

Qualtrics.SurveyEngine.addOnload(function()
{
var pipedText = "${e://Field/PSItemList}";
pipedList = pipedText.replace(/,/g, '
');
Qualtrics.SurveyEngine.setEmbeddedData("PSReformList",pipedList);
});

https://community.qualtrics.com/XMcommunity/discussion/comment/19139#Comment_19139

How are the multiple choice answers saved in the directory?

  1. Is there one embedded data field for each MC question to be populated?

  2. What is the value of the embedded data fields? Selected recodes?


Hi TomG
Here is an example, i've tried both approaches. Yes there are separate directory fields per question.

Q2.1 = QID171
image.pngFor this particular question I have saved three parts in the directory using Workflow Task

1 - "Organisation type" = ${q://QID171/ChoiceGroup/SelectedChoices}
2 - "Organisation type (other)" = ${q://QID171/ChoiceTextEntryValue/10}
3 - OrgTypeRecode = ${e://Field/OrgTypeRecode}

  • OrgTypeRecode = ${q://QID171/SelectedChoicesRecode?format=urlencode}

  • in the surveys workflow prior to sending it to directory


Hope this makes sense, Thanks!


Is OrgTypeRecode stored as comma/space separated in the directory (e.g., 1, 2, 3)?


image.pngHere are the examples from the directory - with format encode enabled it appears as above
Thanks


Personally, I wouldn't url encode the recodes.
You can use JS to prepopulate the org type question like this:
Qualtrics.SurveyEngine.addOnload(function() {
var qobj = this;
var recodes = "${e://Field/OrgTypeRecode}".split("%2C");
jQuery.each(recodes, function(i, val) { qobj.setChoiceValueByRecodeValue(val, true); });
});
The same basic code should work for any MC question as long as the recodes are consistent across surveys. If you don't url encode the recodes the split string would be ", ".
For the text field you can set the default choice to the embedded field "Organisation type (other)".


Thanks TomG
I'll try this out asap and check what happens


TomG This is working now pulling correct ED for the Authenticated users on multichoice questions! Brilliant solution and thank you so much I definitely wouldn't have worked that out!


I'm still looking at other questions where it is a single radio choice; is the best solution for those or to use the solution posted here:
https://community.qualtrics.com/XMcommunity/discussion/comment/18568#Comment_18568
Qualtrics.SurveyEngine.addOnload(function() {
this.setChoiceValueByRecodeValue("${e://Field/T0Q6recode}", true);
});


https://community.qualtrics.com/XMcommunity/discussion/comment/50037#Comment_50037Either works. The code I provided works on both single and multi-select, so you don't have to think about it.



TomG you really went above and beyond to help TomH1! Our team really appreciates your contributions! 👏


What a fantastic thread!


Hi there, this is great @TomG - thank you. Can you suggest how the JS could be changed for a side-by-side question? I imagine you would need to declare several variables like qobj and recodes (one for each column), but not quite sure how to do this as I am a real newbie to JS… Additionally, would this method work for dropdown lists?

For context- I am basically looking at pre-populating the following SBS question with the answers previously given to the same question earlier in the survey (so effectively duplicating it after being completed, to ask the respondent to double check):

 

Any tips are welcome!!


Leave a Reply