For background, I have used qualtrics for several years and I can use workflow to send custom emails based on responses. I am not a coder, but I am trying to learn basic syntax and functions.
I am trying to do something that seems relatively simple and I am running into a problem. I have several surveys that are sent via anonymous links, not emailed directly to people. These surveys are designed to be accessed by anyone via a QR code on a flyer. What I want the respondent to do is first select a name from a list of names, and I want that person that is selected to be sent an email upon survey completion. Each name on the list is followed by their email address (for example John Doe <jdoe@madeupemail.com>). I have tried the following: Create a new Embedded data element called RecipientEmail, then following a page break after the question run the following code on a hidden question:
Qualtrics.SurveyEngine.addOnPageSubmit(function () {
var extractedEmail = "${q://QID1/ChoiceGroup/SelectedChoices}".match(/<(.*?)>/);
Qualtrics.SurveyEngine.setEmbeddedData('RecipientEmail', extractedEmail);
});
I then planned to query the RecipientEmail in the Workflow in the To: part of the email task.
But it does not work and I get a blank value. If I run the code as:
Qualtrics.SurveyEngine.addOnPageSubmit(function () {
var extractedEmail = "${q://QID1/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData('RecipientEmail', extractedEmail);
});
I get the original text. So I know everything is working except the .match function but after looking at countless examples and running a lot of permutations I don’t know what I’m doing wrong. Thanks for any help you can give a novice.