update an embedded data field email domain via JS? | XM Community
Skip to main content
Solved

update an embedded data field email domain via JS?

  • December 3, 2020
  • 2 replies
  • 47 views

MikeB
Level 1 ●
Forum|alt.badge.img+3

Hi,
I am looking for a way to take an embedded data field that contains an email address ie "john . doe @ abc.com" and replace the @abc.com with @xyz and write that back to the same embedded data field.
Can this be done with JS in the survey? Any idea how?
*didnt mean to put this question in 'Best Practices" Please move if needed.

Best answer by ahmedA

old_email = "${e://Field/email}";
old_email = old_email.split("@");
new_email = old_email[0] + "@xyz";
Qualtrics.SurveyEngine.setEmbeddedData("email", new_email);
This should do the trick for you.

2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • December 3, 2020

old_email = "${e://Field/email}";
old_email = old_email.split("@");
new_email = old_email[0] + "@xyz";
Qualtrics.SurveyEngine.setEmbeddedData("email", new_email);
This should do the trick for you.


MikeB
Level 1 ●
Forum|alt.badge.img+3
  • Author
  • Level 1 ●
  • December 4, 2020

Beautiful, thank you ahmedA worked perfectly!