Nested "if" statements in email notification field

More
6 months 2 weeks ago #166714 by evinsmj
evinsmj created the topic: Nested "if" statements in email notification field
Hi everyone!

I did some searching on the forum and found a solution for conditionally sending email notifications to an email address based on the answer to a question from within the survey. However, when I try to nest the statements, I can't get it to work. Here's the situation...

I have a question (code: dropdown) that has a list of names. Depending on which name is selected, I need that individual to receive an email notification on submission.

This works: {if(dropdown.code=="A1","This email address is being protected from spambots. You need JavaScript enabled to view it.","")}

But when I try to nest the if statements for multiple possible recipients, it doesn't work. Here is what I have:

{if(dropdown.code=="A1","email1@test.com",{if(dropdown.code=="A2","email2@test.com","")})}

Not only does the recipient for A2 not receive anything, but not even the recipient for A1. Any thoughts as to why the nested statements don't work?

Thanks!

Please Log in or Create an account to join the conversation.

More
6 months 2 weeks ago - 6 months 2 weeks ago #166725 by Joffm
Joffm replied the topic: Nested "if" statements in email notification field
Hi,
your statement is wrong.

{if(condition,true,false)}
And the false-part can be replaced by a new if-statement
{if(condition,true,
      if(condition,true,
            if(condition,true,
                  if(condition,true,false)
            )
      )
)}

So, remove the curly braces in the middle:
{if(dropdown.code=="A1","email1@test.com",if(dropdown.code=="A2","email2@test.com",""))}

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last Edit: 6 months 2 weeks ago by Joffm.
The following user(s) said Thank You: DenisChenu, LouisGac

Please Log in or Create an account to join the conversation.

More
6 months 2 weeks ago #166727 by evinsmj
evinsmj replied the topic: Nested "if" statements in email notification field
I'm not sure why the curly braces were a problem, but your suggestion definitely fixed the issue. Thank you!!

Please Log in or Create an account to join the conversation.

More
6 months 2 weeks ago #166731 by holch
holch replied the topic: Nested "if" statements in email notification field
The curly braces are a problem because it indicates a new expression to start (without closing the previous one), which is not what you want to do. It is still the same expression, just with a nested "if" statement.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
The following user(s) said Thank You: DenisChenu, LouisGac

Please Log in or Create an account to join the conversation.

More
6 months 2 weeks ago #166734 by evinsmj
evinsmj replied the topic: Nested "if" statements in email notification field
Got it - thanks for the explanation!

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!