- Posts: 1
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Email template, content should depend on answers given in survey
- timdec19
- Topic Author
- Offline
- New Member
Less
More
4 years 6 months ago #189330
by timdec19
Email template, content should depend on answers given in survey was created by timdec19
I have a survey with a signup form with 2 questions:
- textfield for email
- dropdown selection list with options like 'student', 'teacher', etc
After completing the survey the user should receive an automatic email (this works already) but the content should depend on the signup type, as teachers have to pay less than students.
I have been trying something like this in the email template field:
But this does not work. What is the correct way of using such logic expressions in the email?
- textfield for email
- dropdown selection list with options like 'student', 'teacher', etc
After completing the survey the user should receive an automatic email (this works already) but the content should depend on the signup type, as teachers have to pay less than students.
I have been trying something like this in the email template field:
Code:
Thanks for signing up! {if(signup_type=="A1")} { Please pay €5 } {if(signup_type=="A2")} { Please pay €10 }
But this does not work. What is the correct way of using such logic expressions in the email?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
4 years 6 months ago - 4 years 6 months ago #189333
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Email template, content should depend on answers given in survey
Your code is completely wrong, so I assume this is the problem here. I am assuming that "signup_type" and A1, A2, etc. are correct, then you should try this code:
It is always like this {if(condition that triggers something, what happens when condition is met, what happens when condition is not met)}
Or, assuming that there is only signup type A1 and A2 you could write this shorter:
I would always try this code within the survey first (e.g. in a text display question or an equation question) and see if it works there (easier to make sure the code works, because you do not need to send an email each time). Once the code works, then you can try it in the email template.
Actually, I probably would use a hidden equation question for this and in the email Template I would probably just pipe the content of this Equation question into the email. This way it is even saved in the database.
Code:
{if(signup_type=="A1", "Please pay €5", "")} {if(signup_type=="A2", "Please pay €10", "")}
It is always like this {if(condition that triggers something, what happens when condition is met, what happens when condition is not met)}
Or, assuming that there is only signup type A1 and A2 you could write this shorter:
Code:
{if(signup_type=="A1", "Please pay €5", "Please pay €10")}
I would always try this code within the survey first (e.g. in a text display question or an equation question) and see if it works there (easier to make sure the code works, because you do not need to send an email each time). Once the code works, then you can try it in the email template.
Actually, I probably would use a hidden equation question for this and in the email Template I would probably just pipe the content of this Equation question into the email. This way it is even saved in the database.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 4 years 6 months ago by holch.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12923
- Thank you received: 3977
4 years 6 months ago #189334
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Email template, content should depend on answers given in survey
And in addition to holch's explanation:
You find all this here:
manual.limesurvey.org/Expression_Manager...mplemented_functions
and here
manual.limesurvey.org/Expression_Manager_how-tos
Joffm
You find all this here:
manual.limesurvey.org/Expression_Manager...mplemented_functions
and here
manual.limesurvey.org/Expression_Manager_how-tos
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- BusyBonsai
- Offline
- Junior Member
Less
More
- Posts: 35
- Thank you received: 0
3 years 11 months ago #198766
by BusyBonsai
Replied by BusyBonsai on topic Email template, content should depend on answers given in survey
Hi guys. I am used to the if-functions syntax and using it in question texts etc. on a regular basis. However, right now I am trying to implement it in the email invitation template and it seems to just swallow up the curly brackets. See my attempts below.
I am using LS version 2.73.0+171219 for this.
And the screenshot shows it's validating properly clicking on the "Validate expressions" button.
Guess I need some captain obvious here.
I am using LS version 2.73.0+171219 for this.
Code:
<html> <head> <title></title> </head> <body> <p>{if(TOKEN:ATTRIBUTE_1 == "1", "Lieber Kollege Prof. ", "")} {if(TOKEN:ATTRIBUTE_1 == "2", "Liebe Kollegin Prof. ", "")}{if(TOKEN:ATTRIBUTE_1 == "1", "Lieber Kollege Prof. ", if(TOKEN:ATTRIBUTE_1 == "2", "Liebe Kollegin Prof. ", "Sehr geehrte*r Prof. "))}{LASTNAME},<br />
And the screenshot shows it's validating properly clicking on the "Validate expressions" button.
Guess I need some captain obvious here.
Attachments:
The topic has been locked.
- BusyBonsai
- Offline
- Junior Member
Less
More
- Posts: 35
- Thank you received: 0
3 years 11 months ago #198782
by BusyBonsai
Replied by BusyBonsai on topic Email template, content should depend on answers given in survey
Edit: email I am receiving looks like this
Attachments:
The topic has been locked.
- BusyBonsai
- Offline
- Junior Member
Less
More
- Posts: 35
- Thank you received: 0
3 years 11 months ago #199457
by BusyBonsai
Replied by BusyBonsai on topic Email template, content should depend on answers given in survey
Hi there.
Turns out that - within EMail-templates - instead of "TOKEN:ATTRIBUTE_1" you need to write "ATTRIBUTE_1" only. It works fine now for me.
Cheers
Turns out that - within EMail-templates - instead of "TOKEN:ATTRIBUTE_1" you need to write "ATTRIBUTE_1" only. It works fine now for me.
Cheers
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11658
- Thank you received: 2742
3 years 11 months ago #199492
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Email template, content should depend on answers given in survey
Yes, this is one of these little "inconsistencies" that can drive you nuts. I don't understand why this is not consistent, but it is the way it is.
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.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13643
- Thank you received: 2491
3 years 11 months ago #199502
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Email template, content should depend on answers given in survey
If i don't make error in 3.X : you can use TOKEN:ATTRIBUTE_1 or ATTRIBUTE_1
If you can not in 4.X : it's a (major) issue
If you can not in 4.X : it's a (major) issue
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.