Email Trigger Piped Multiple Choice Formatting | XM Community
Skip to main content

Hi All:

 

Hoping to get some advice on whether formatting on a multiple choice question is possible.

After piping out the multiple choice text in a email trigger, the choices appear on a single line.

 

For example:

 

d ] Workshop 1, Aug 1, 2023

dx] Workshop 2, Aug 2, 2023

dx] Workshop 3, Aug 3, 2023

d ] Workshop 4, Aug 4, 2023

dx] Workshop 5, Aug 5, 2023

 

Would be piped in the email trigger as:

Workshop 2, Aug 2, 2023, Workshop 3, Aug 3, 2023, Workshop 5, Aug 5, 2023

 

What I was hoping to do is to have:

Workshop 2, Aug 2, 2023

Workshop 3, Aug 3, 2023

Workshop 5, Aug 5, 2023

 

Any guidance would be appreciated.

 

 

Use JS to modify the piped string and save it as an embedded data field that you can pipe into your email:

var pipedAnswers = "${q://...}".replace(/, /g,"<br>");
Qualtrics.SurveyEngine.setEmbeddedData("pipedAnswers",pipedAnswers);

 


Thanks @TomG !

 

Do you know how I would pipe the variable into the email template?


Thanks @TomG !

 

Do you know how I would pipe the variable into the email template?

In the example I gave, it would be ${e://Field/pipedAnswers}


I’m getting a blank string when I console log the pipedAnswer.

 

For “${q://...}” do I need to replace the “...” with the question id?  Is there a way to determine what that is?


Yes, you need to replace ${q://...} with the actual piped string that contains your question’s selected choices. You also need to put the code inside an appropriate function such as Qualtrics.SurveyEngine.addOnload(). 


When i try to do something like this:

jQuery("#"+this.questionId+" .InputText")

 

I get the following error:

SE API Error: TypeError: jQuery(...).replace is not a function


When i try to do something like this:

jQuery("#"+this.questionId+" .InputText")

 

I get the following error:

SE API Error: TypeError: jQuery(...).replace is not a function

You’ve tried to use replace on a jQuery object instead of a string.  This seems unrelated to your original question since the jQuery command would be for a text entry field.


I see what you mean.

 

This is what I ended up with, but still getting an empty string:

Qualtrics.SurveyEngine.addOnPageSubmit(function() {

var pipedAnswers = "${q://QID1/ChoiceGroup/SelectedChoices}".replace(/, /g,"<br>");

Qualtrics.SurveyEngine.setEmbeddedData("pipedAnswers",pipedAnswers);

    console.log("pipedAnswers",pipedAnswers)

});

 

In my email trigger I have:

${e://Field/pipedAnswers}


That script can’t be on the same page as QID1 (the pipe of QID1 would be empty).


Thanks for the help @TomG !  Worked like a charm!


Leave a Reply