Pushing out an email through JavaScript | XM Community
Skip to main content

I am seeking support in developing a survey that is accessible for three parties to complete three different sets of questions. Essentially, I am trying to develop one survey that can be sent for 2-3 individuals to provide answers to assigned sections. 

I would need the survey to stay active until all parties complete their section, which means a retake link cannot be used due to the survey being marked as incomplete before being sent to the next person. 

I was able to create a survey where at the end of each section JavaScript was embedded so the forward arrows would not show. This would prevent the survey participant from moving forward and completing a section that was not meant to be completed by them. I then created a custom URL using the survey ID number and would like to forward that in an email to the next party. I linked the specific URL to the specific section created for the receiving participant. 

The challenge I am now having is writing the JavaScript code to be linked to a question/page so that once that question/page is displayed, it will prompt the email to be sent to the next party. I have provided the JavaScript code that I tried below. However, there must be an error in that code because I cannot get it to prompt the email. 

 

Code:

Qualtrics.SurveyEngine.addOnUnload(function() {

    Email.send({

        SecureToken: "mail-relay.iu.edu",

        To: "${q://QID8/ChoiceTextEntryValue/5}",

        From: carserv@iuk.edu,

        Subject: "Thank you for participating",

        Body: "Thank you for taking our survey. https://iu.co1.qualtrics.com/jfe/form/SV_0ebVabPJUIDfQz4?Faculty=${rm://Field/ResponseID}",

Why don’t create different blocks and set logics for those blocks to be seen only if the value is met based on an embedded data? That would be easier and without js!


I initially thought about creating those different blocks and setting them to only be seen based on embedded data, however, that would not prompt an email for the survey to be sent to the next party to complete their section. 


@mdavis296,

Email.send isn’t a valid JavaScript function. Unless you’ve loaded some type of JavaScript email api library it isn’t going to work.

An alternative would be to create a mailto link and have the respondent click on it, but that would rely on the email client on their device being set up properly.

 


Leave a Reply