I have an Embedded Data variable ${e://Field/ My_multiline_text }, which will store a mutiline text
I need a JS code which appends a string and put it on the new line, depending on survey answers. Something like the following:
var p2Text = "${q://QID1/ChoiceGroup/SelectedChoices}";
if (p2Text =="Yes") {
Qualtrics.SurveyEngine.Append_EmbeddedData("My_multiline_text", "Hello baby" );
}
p2Text = "${q://QID2/ChoiceGroup/SelectedChoices}";
if (p2Text =="Yes") {
Qualtrics.SurveyEngine.Append_EmbeddedData("My_multiline_text", "I love you baby" );
}
p2Text = "${q://QID3/ChoiceGroup/SelectedChoices}";
if (p2Text =="Yes") {
Qualtrics.SurveyEngine.Append_EmbeddedData("My_multiline_text", "I miss you baby" );
}
So at the end of the survey, ${e://Field/ My_multiline_text } would contain a multiline text:
Hello baby
I love you baby
I miss you baby
I am going to pipe in ${e://Field/ My_multiline_text } into my email trigger message body.
Thanks!
Solved
Looking for JS to append a string to an Embedded Data variable
Best answer by pogi
You can concatenate Embedded Data simply by adding
new_text = ${e://Filed/My_multiline_text} + "\\n" + "Hello baby";
Qualtrics.SurveyEngine.setEmbeddedData( 'My_multiline_text', new_text);
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.