Hi folks,
I've chased this a bunch of different ways and am getting nowhere so any help would be truly appreciated. I have created a Directory and Contact List and added a custom field that I want to use within a survey (embedded data). This field would match up the following:
Field name = COLOR
What is your favorite primary color?
Red
Yellow
Blue
I have also created a Project / Survey that has the EXACT same question.
When a user takes the survey I want it to prepopulate the survey question with the preloaded response from the embedded data showing the question and allowing the user to either change their response or choose a new one.
And then I want to update the embedded data field in the Directory and Contact List with their updated response.
ChrisS
I'm not sure if you have javascript or are looking for ways to do this without a javascript license so I am giving you both solutions.
First in your survey flow, make sure you are reading in COLOR as an embedded data field before you run into the question What is your favorite primary color?
If you have javascript you can put this in your primary color question:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Plase your Javascirpt here to run when the page loads */
//assing the value from teh embedded data field COLOR
var color = "${e://Field/COLOR}";
//set default according to color where the recode values are red = 1; yellow = 2 and blue = 3
if(color == "red" || color == "Red" || color = "RED"){
this.setChoiceValue(1, true);
}
else if (color == "yellow" || color == "Yellow" || color == "YELLOW"){
this.setChoiceValue(2, true);
}
else if (color == "blue" || color == "Blue" || color == "BLUE"){
this.setChoiceValue(3, true);
}
});
If you don't have javascript then you want to create three instances of this question where each has it's own unique display logic and default value selected.
Then in your survey flow after the question or questions is asked, you can create a variable COLOR2 that will pipe in the selected choice (JS) or pipe in the response to the three questions if you aren't using JavaScript. The result will be "Red", "Yellow" or "Blue" because they will only see one of the three questions. Do not put spaces between the piping or it will make your text value weird.
Lastly, create a Workflow that triggers when a survey is submitted. You will then choose XM Directory add contact info or distribute a survey. On the next screen select Add to XM directory. Fill in the form, connect your contact list then choose Add or Remove embedded data fields. Create a field for COLOR and pipe in the value either COLOR2 or COLOR2JS. That will overwrite their newly selected color from the color that was stored at the start of the survey.
(Picture assumes you are using JavaScript)
(leave the defaults to Save or update it as embedded data to your XM directory contacts and Update recipient from survey response)
Attached is the .qsf but it doesn't have the workflow saved because I don't have an appropriate contact list to show you in this example.
default color.qsf
You are amazing!! This works like a charm!!! Thank you sooo much :)
ChrisS great to hear you got it implemented!
bstrahin Quick follow up question.
Is there a way to implement this with a multi select question?
Of note, we used the Java Script method you detailed above.
Thanks in advance :)
https://community.qualtrics.com/XMcommunity/discussion/comment/53400#Comment_53400ChrisS this is a fairly simple adjustment to the JavaScript. Instead of "==" operator you will use variable.includes("value") for your logic and instead of else if just use if.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
//assign the value from the embedded data field COLOR
var color = "${e://Field/COLOR}";
if(color.includes("red") || color.includes("Red") || color.includes("RED")){
this.setChoiceValue(1, true);
}
if (color.includes("yellow") || color.includes("Yellow") || color.includes("YELLOW")){
this.setChoiceValue(2, true);
}
if (color.includes("blue") || color.includes("Blue") || color.includes("BLUE")){
this.setChoiceValue(3, true);
}
});
For storage, you shouldn't have to change anything because it is already pulling in all selected choices. It will format with a comma between the multiple selected values.
That also worked perfectly! Thanks again :)
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.