email survey response to participant

More
4 years 8 months ago #83294 by alexmessinger
I would like to email a copy of the completed survey to the recipient upon submit. Is this possible?

Please Log in to join the conversation.

More
4 years 8 months ago - 4 years 8 months ago #83297 by Ben_V
Have a look at the doc and/or at this previous post

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last Edit: 4 years 8 months ago by Ben_V.

Please Log in to join the conversation.

More
4 years 8 months ago #83331 by alexmessinger
Hi Benitov,

This shows me how to send a copy to the admin, but not to the recipient. I would like to send a copy of the completed survey to the recipient.

Please Log in to join the conversation.

More
4 years 8 months ago #83344 by Ben_V
look again at those links ;)
The way for e-mailing responses to participant is fully and correctly explained.
> Notification & data management
>>1.
>>>2.
Ben/

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)

Please Log in to join the conversation.

More
4 years 8 months ago #83364 by eltito
Hi,

You can adapt my example to your needs.
First, you need to put a callback on the message end screen. For this, see javascript code below. It will call a PHP script with the email, survey ID and the DB field name for email storage.
$(document).ready(function() {
  var d = new Object();
  d.email = '{INSERTANS:SGQA}';
  d.sid = '{SID}';
  d.fn = 'SGQA';
    $.ajax({
      type: 'POST',
      url: 'checkmail.php',
      data: d,
      success: function(t){console.log(t)}
    });
  });

Next, you need the server side script which will check and process sent datas. In my case, it delete all duplicated surveys for a given email address. You have to change it to your needs. I don't know how you could get a human readable resulte but it seems to be the same logic as my case.
$query = "SELECT $fieldName FROM {$dbprefix}survey_{$surveyid}\n"
. "WHERE $fieldName = ".db_quoteall(sanitize_email($email));
$result = $connect->Execute($query) or safe_die ($query."<br />".$connect->ErrorMsg());
if (($result->RecordCount()) > 0)
{
    $connect->Execute("DELETE n1 FROM {$dbprefix}survey_{$surveyid} n1, {$dbprefix}survey_{$surveyid} n2 WHERE n1.{$fieldName} = ".db_quoteall(sanitize_email($email))." AND n1.id > n2.id AND n1.{$fieldName} = n2.{$fieldName}");
    if ( $connect->Affected_Rows() ) {
        die('done');
    } else {
        die('fail');
    }
} else {
    die('useless');
}
The delete statement have to be replace by for example :
"SELECT n1.* FROM {$dbprefix}survey_{$surveyid} n1 WHERE n1.{$fieldName} = ".db_quoteall(sanitize_email($email))

This will get all the survey informations for an email address. I let you have a look at INSERTANS:SGQA on the wiki. The big part will be the mail creation, if you want a human readable email...

Hope it helps.
Regards.

Please Log in to join the conversation.