Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Can I send email conditionally, based on a question response?

More
11 years 11 months ago - 11 years 11 months ago #77265 by Ben_V

By the student selecting the school they attend, the detailed notification email will be sent to that principal's email


Maybe you can do something like this:

1) Create an email account dedicated to this survey for e.g using Gmail (mysurvey1email@gmail.com), because Gmail offers efficient features regarding filters & messages transfer. This account will collect all responses for further dispatching.

2) Set your survey to send email detailed notification (with full responses) to mysurvey1email@gmail.com.

3) In the parameters of mysurvey1email@gmail.com account set filters for redirecting all incoming emails automatically to differents email addresses depending on keywords included in the message body(=answers):
- If "Lucky Town" in the body" transfer to 'principal@luckytown.edu
- If "Down Town" in the body" transfer to 'principal@downtown.edu
- etc.

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)
Last edit: 11 years 11 months ago by Ben_V.
The topic has been locked.
More
6 years 6 months ago #158258 by dotxm
I created a new topic for the answer, in here.

This is the solution I found:

The need
Send a detailed message to the survey admin, if a specific question gets a specific answer

The solution
Instead of an email address, put a condition like so:
{if(QUESTIONCODE.code=="ANSWERCODE","EMAIL","")}

The text you need to change is in orange.

Example implementation (tested on 2.67.3):
Code:
{if(RequestsContact.code=="Y","someone@somewhere.com","")}

The option is under:
'Survey properties > General settings & texts > Notification & data management > Send detailed admin notification email to:'


All the best,
Dotan
The following user(s) said Thank You: wilberth, cdorin, chuchocosta
The topic has been locked.
More
4 years 7 months ago #187038 by chuchocosta
the solution works ok, thank you so much. I have version 3.17.4
The topic has been locked.
More
4 years 3 months ago - 4 years 3 months ago #191915 by Kyler_Hunter
Dotxm,
I've been trying to use your code on an Array question (1-10 radio choice). However I've not been able to get it to work plus I need it to be for various answers (basically if anyone answers 8 or lower). I've tried the following:
Code:
{if(P1Q1_SQ001.code=="[A1]", "someone@somewhere.com", "")else if(P1Q1_SQ001.code=="[A2]", "someone@somewhere.com", "")}
But it doesn't send the email. Did I write this wrong somehow?
I'm on version 3.17
Last edit: 4 years 3 months ago by Kyler_Hunter.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191916 by tpartner
There is no "else if" in Expression Manager, it uses nested IFs like Excel - manual.limesurvey.org/Expression_Manager_-_presentation#Syntax

Also, there are no square braces required in Expression manager.

That said, if you change the answer code to numerics 1-10, you could do something like this:

Code:
{if(intval(P1Q1_SQ001) <= 8, "someone@somewhere.com", "")}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Kyler_Hunter
The topic has been locked.
More
4 years 3 months ago #191919 by Kyler_Hunter
Dude you are awesome! It worked!

On a slight side note the generated answer table ...well it sucks. To much info and the formatting is terrible. Is there a way to use Expression Manager to pull the Questions , sub-question and answers and format them the way I want and not have to go into the actual PHP code (we're not suppose to but I don't want to say no we cannot)?

Example :
"Question:
- Sub-Question: Answer"


Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191921 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
4 years 3 months ago - 4 years 3 months ago #191964 by Kyler_Hunter
tpartner,

I love clients. New requirement is that any of the rating question now if answered 8 or lower send an email. I've tried various combinations of the code you gave me and as long as only one of the question is 8 or below we get the email, but if all ratings are 8 or below no email shows up.

I've tried the following:
Code:
{if(intval(P1Q1_SQ001) <= 8, if (P1Q2_SQ001) <= 8, if(P1Q3_SQ001) <= 8, "someone@somewhere.com", ""))))}
and
Code:
{if(intval(P1Q1_SQ001) <= 8, "someone@somewhere.com", "")}{if(intval(P1Q2_SQ001) <= 8, "someone@somewhere.com", "")}{if(intval(P1Q3_SQ001) <= 8, "someone@somewhere.com", "")}
Is there a way to write this so the email gets sent if any combination occurs?
Last edit: 4 years 3 months ago by Kyler_Hunter.
The topic has been locked.
More
4 years 2 months ago #192726 by kate92
I have similar problem. I'm trying to send detailed admin mail but based on an answer to a specific question. The problem is, the answer is short text, situation description.

How should I change this:

{if(QUESTIONCODE.code=="ANSWERCODE","EMAIL","")}.

My questioncode is P11, question tipe is short text (Describe situation). And the answer is situation description.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago #192728 by tpartner
So, you want to send the email if anything is entered in P11?

In that case:

Code:
{if(!is_empty(P11), "EMAIL", "")}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose