Hi everyone.
I'm trying to set up a survey so that it will email the results to an instructor. I have already set up the workflow and believe that this will work correctly. (I've done this before and it has worked fine, so I think I'm OK with this part of the process.)
But I'm having trouble extracting the instructor email from the response for use in the workflow. Here's the setup:
One question asks students to select their instructor from a drop down list. That drop down contains the instructor's name and their email address in the format "First Last - email@email.com".
I want to extract the email from this response to use in the "to" field for the email. I have created an embedded data object called "EmailSuffix". I then worked with MS Copilot to write some javascript that should extract the email from the response and save it to the Embedded Data. But no matter what I try, it seems like the response isn’t recording to the embedded data.
(Note, I’ve tried to debug this by first just recording the response, without the splitting. That doesn’t work. I then tried to get the script to just write a hardcoded value “test” into the embedded data, and that was OK).
I am very new to this, though, so I have quickly run out of things to try. Any help would be GREATLY appreciated.
This is the code I was working with.
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var response = this.getSelectedChoices();
if (response.length > 0) {
var fullText = this.getChoiceText(responsee0]);
var parts = fullText.split(" - ");
if (parts.length > 1) {
Qualtrics.SurveyEngine.setEmbeddedData("EmailSuffix", partsS1].trim());
}
}
});