Welcome to the LimeSurvey Community Forum

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

conditional statement in email

  • Haringsma
  • Haringsma's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 5 months ago #125931 by Haringsma
conditional statement in email was created by Haringsma
I'm sending the results of a questionnaire to the person that filled in the survey. I came so far that the results show in the email, by using the following statement that I found in the manual:

{if(ASSESVALUE>10,'Good','Bad')}

This code only gives me two possibilities though, Good when the score is higher than 10 and bad when the score is lower. I need to have some more possibilities though. 5 to be exact*. But I can't make the conditional statement work. Can anybody help me with that?

* So that it goes like:
if score is lower than 5, feedback shown is: you are bad
if score is lower that 10, feedback shown is: you are not good
if score is lower than 15, feedback shown is: you are neutral
if score is lower than 20, feedback shown is: you are quite good
if score is lower than 25, feedback shown is: you are the master
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 5 months ago #125932 by holch
Replied by holch on topic conditional statement in email
You will have to create nested if statements. ideally I would write the result of these nested "if" statements into an equation and then just reference to the result of this equation question.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 5 months ago #125933 by Mazi
Replied by Mazi on topic conditional statement in email

holch wrote: You will have to create nested if statements. ideally I would write the result of these nested "if" statements into an equation and then just reference to the result of this equation question.

That's right. It will look like this (untested):
{if(ASSESVALUE<5,'Bad',if(ASSESVALUE<10,'not good',if(ASSESVALUE<15,'neutral',if(ASSESVALUE<20,'quite good',if(ASSESVALUE<25,'master','')))))}

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
8 years 2 months ago #130065 by levilarsen
Replied by levilarsen on topic conditional statement in email
I am also trying to include a conditional expression in the confirmation or notification email template. When I run the survey the email that is generated just shows the code and never evaluates the expression.

To be sure I wasn't missing something I just copied the code used in this thread and changed "ASSESVALUE" to a question code from my survey FINQ2.

Both the template and the email that are generated show exactly this: {if(FINQ2>10,'Good','Bad')}

How do I get the expression to be evaluated before the email gets sent?
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 2 months ago #130086 by Mazi
Replied by Mazi on topic conditional statement in email
Hard to say what goes wrong...

1. What question type are you using at FINQ2?

2. Can you paste a screenshot of the question logic file of that question?

3. Which Limesurvey version do you use?

4. Did you try using FINQ2.NAOK or FINQ2.valueNAOK instead?

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
8 years 1 month ago - 8 years 1 month ago #130145 by levilarsen
Replied by levilarsen on topic conditional statement in email
1.What question type are you using at FINQ2 (now FINQ1)?
text, i've also tried it as a number field and was unsucessful. see attached.

2. Can you paste a screenshot of the question logic file of that question? attached.

3. Which Limesurvey version do you use? 2.05

4. Did you try using FINQ2.NAOK or FINQ2.valueNAOK instead? yes, see attached.
Last edit: 8 years 1 month ago by levilarsen.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 1 month ago #130147 by Mazi
Replied by Mazi on topic conditional statement in email
try:
{if(FINQ2.NAOK gt 0, "Text A", "Text B")}

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
8 years 1 month ago #130148 by levilarsen
Replied by levilarsen on topic conditional statement in email
Works Awesome! Thanks for correcting my syntax. :cheer:

For others' reference this worked both with a numerical input and short free text input. Note that a validation statement was used to ensure numbers were being entered into the text question.
The topic has been locked.
More
3 years 10 months ago #198114 by wahoowa
Replied by wahoowa on topic conditional statement in email
Hi everybody,

I also have a question regarding the conditional statements in emails.

The solution from Mazi works for me when I work with short sentences. But I run into problems, when I try to format the conditonal text (Ideally, I would like to present several paragraphs for each condition including some words that are in bold print and some words that are colored).

My question is, if I need to use additional brackets or something else if I want to format the text?

Thank you in advance!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #198119 by Joffm
Replied by Joffm on topic conditional statement in email

{if(FINQ2.NAOK gt 0, "Text A", "Text B")}


Hi,
this is the normal behaviour of the IF-statement used in micro-tayloring.

If your TRUE- and FALSE-parts contain HTML tags you have to care of nested brackets.
"This is <span style="color:red">my</span> car." is not allowed,
you have to use
"This is <span style='color:red'>my</span> car."

But beware: The LS editor tries to change single quots to doubles each time you open.
So enter and save and do not touch again.

Well, that was talked in general.
Without seeing what you are trying to achieve, it is difficult to advise.
Best you show us your message(s), the real structure, but - if you want - with blind text.

Joffm

By the way:
The field in the database is of type "text" -> up to 65000 characters.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: wahoowa
The topic has been locked.
More
3 years 10 months ago #198307 by wahoowa
Replied by wahoowa on topic conditional statement in email
Thank you Joffm!

Changing " to ' for the colar-tag did the job.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose