Extracting username part from an email address | XM Community
Skip to main content
Question

Extracting username part from an email address

  • June 22, 2020
  • 6 replies
  • 22 views

Forum|alt.badge.img

From email address in format "Username@@mylaurier.ca", I need to extract "Username" and pipe it into "Reply-To Email" as ${e://Field/myUserName}.
So basically, my Java script has take "Username@@mylaurier.ca" and delete the part "@mylaurier.ca" and write "Username" into ${e://Field/myUserName}.
My JS code is:
var EmailAdr= "${q://QID13/ChoiceTextEntryValue}";
var UserNameTemp = EmailAdr.match(/^(@mylaurier.ca)@/)[1];
Qualtrics.SurveyEngine.setEmbeddedData("myUserName", UserNameTemp);
The above code is not working. ${e://Field/myUserName} returns empty string.
I suspect a problem with EmailAdr.match(/^(@mylaurier.ca)@/)[1];

The task is motivated by unwelcomed transition from deprecated triggered Email to "Tasks" , where "Reply-To Email" will be set as concatenation of ${e://Field/myUserName} and "@mylaurier.ca" as discussed https://www.qualtrics.com/community/discussion/9980/upcoming-deprecation-of-new-survey-triggers-june-30th

6 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • June 22, 2020

Try:
var splitEmail = "${q://QID13/ChoiceTextEntryValue}".split("@");
Qualtrics.SurveyEngine.setEmbeddedData("myUserName", splitEmail[0]);


Forum|alt.badge.img
  • Author
  • Level 1 ●
  • June 22, 2020

Actually, I tried
var UserNameTemp  =EmailAdr.substring(0, EmailAdr.lastIndexOf("@"));
Qualtrics.SurveyEngine.setEmbeddedData("myUserName", UserNameTemp);

and ${e://Field/myUserName} does return the username as I wanted.
But now there is another problem. It seems ${e://Field/myUserName} is not properly piped into "Reply-To Email:". See attached image
Capture.PNGWhen the received email is clicked on Reply-to, the expected reply email address is not there. "Reply-to" worked seamlessly in the deprecated triggered email, but is not working is Actions> Tasks as shown above.
I also tried to pipe with quotation marks "${e://Field/myUserName}", but no good.
What's wrong? Or how otherwise to pipe into "Reply-To Email:"?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • June 22, 2020

Contact Qualtrics Support.


Forum|alt.badge.img
  • Author
  • Level 1 ●
  • June 22, 2020

I contacted the support. They say that piping into "Reply-To Email:" is not supported in "Actions"


Forum|alt.badge.img
  • Author
  • Level 1 ●
  • June 22, 2020

It's absolutely unacceptable!


MaiaH
Qualtrics Employee
Forum|alt.badge.img+1
  • Qualtrics Employee
  • June 22, 2020

HI Alex_WLU, if you haven't already, please consider posting this functionality as a Product Idea on Community! :)