Welcome to the LimeSurvey Community Forum

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

Nested "if" statements in email notification field

  • evinsmj
  • evinsmj's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 weeks ago #166714 by evinsmj
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","email1@test.com","")}

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



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!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 weeks ago - 6 years 2 weeks ago #166725 by Joffm
Hi,
your statement is wrong.

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

So, remove the curly braces in the middle:


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 2 weeks ago by Joffm.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • evinsmj
  • evinsmj's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 weeks ago #166727 by evinsmj
I'm not sure why the curly braces were a problem, but your suggestion definitely fixed the issue. Thank you!!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 weeks ago #166731 by holch
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 answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • evinsmj
  • evinsmj's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 weeks ago #166734 by evinsmj
Got it - thanks for the explanation!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose