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

Email Trigger Piped Multiple Choice Formatting

  • Sep 12, 2023 1:01 PM UTC
  • 10 replies
  • 152 views

Forum|alt.badge.img+1

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:

 

[ ] Workshop 1, Aug 1, 2023

[x] Workshop 2, Aug 2, 2023

[x] Workshop 3, Aug 3, 2023

[ ] Workshop 4, Aug 4, 2023

[x] 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.

 

 

Best answer by TomG

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);

 

View original

10 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • Sep 12, 2023 1:37 PM UTC

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);

 


Forum|alt.badge.img+1
  • Author
  • Sep 12, 2023 1:44 PM UTC

Thanks @TomG !

 

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Sep 12, 2023 1:46 PM UTC

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}


Forum|alt.badge.img+1
  • Author
  • Sep 12, 2023 1:56 PM UTC

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?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Sep 12, 2023 1:59 PM UTC

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(). 


Forum|alt.badge.img+1
  • Author
  • Sep 12, 2023 2:18 PM UTC

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


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Sep 12, 2023 2:44 PM UTC

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.


Forum|alt.badge.img+1
  • Author
  • Sep 12, 2023 3:03 PM UTC

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}


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Sep 12, 2023 3:36 PM UTC

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


Forum|alt.badge.img+1
  • Author
  • Sep 12, 2023 4:37 PM UTC

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