conditional statement in email

More
5 years 2 days ago #125931 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

Please Log in to join the conversation.

LimeSurvey Partners
More
5 years 2 days ago #125932 by holch
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.

Please Log in to join the conversation.

More
5 years 2 days 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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
4 years 8 months ago #130065 by levilarsen
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?

Please Log in to join the conversation.

More
4 years 8 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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
4 years 8 months ago - 4 years 8 months ago #130145 by levilarsen
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.
Attachments:
Last edit: 4 years 8 months ago by levilarsen.

Please Log in to join the conversation.

More
4 years 8 months 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
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Please Log in to join the conversation.

More
4 years 8 months ago #130148 by levilarsen
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.

Please Log in to join the conversation.

More
4 months 3 weeks ago #198114 by wahoowa
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!

Please Log in to join the conversation.

More
4 months 3 weeks ago #198119 by Joffm

{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

Please Log in to join the conversation.

More
4 months 3 weeks ago #198307 by wahoowa
Thank you Joffm!

Changing " to ' for the colar-tag did the job.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now