Welcome to the LimeSurvey Community Forum

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

email-template -> if statement with placeholder/token does not work

  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177406 by mad99
Hi forum,
I'm new in limesurvey and I like it a lot!

Unfortunatelly I can't figure out, why the email-template does not replace the placeholder correctly.
Found a lot of topics about the right using. And I guess I have used the if-condition and placeholder in the right way.

But at the end, in the inbox, the Placeholder/Tokens used in the {if}-conditions are still empty, although the Token as it own is replace correctly.

Would be great to get a push in the right direction.

The email-tempalte



The second line «Token {TOKEN:ATTRIBUTE_1}, the Placeholder/Token is replaced right in the emial. (Value is «DU»)
But all the other lines with {if}-conditions the replacing is not working.

The email rendered in the inbox


Also the validation show's NO-errors



Would be great to get help for.
juicy regards
Martin
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177410 by DenisChenu
{if(TOKEN:ATTRIBUTE_1 == "Du",'Hey '+TOKEN:ATTRIBUTE_1,'Du-no')}

You are already inside an equation, you must use equation system.

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.
  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago - 5 years 4 months ago #177422 by mad99
Thank you DenisChenu for help. I did «copy & paste» a working template from text-tab.
So I used your advice and it does not change anything. To be sure to type right I «copy&paste»'d your code 1:1.



Unfortunatelly with same end-result. There is no output in the email with your code too.



[hr]

Tried also WITHOUT TOKEN-ELEMENT IN OUTPUT:



SAME Problem -> NO output in email for if-statement:


Any other sugesstions/ideas?
Last edit: 5 years 4 months ago by mad99.
The topic has been locked.
  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177423 by mad99
Could it be a bug?



LIne 1+2+3 > I tried with FIRSTNAME -> WORKS FINE!
Line 4: > I tried same with copy-paste and replace «FIRSTNAME» with «ATTRIBUTE_1» -> IT DOES NOT WORK.
Line 5: > Output value from «ATTRIUBTE_1» -> WORKS FINE!

I copy&paste ATTRIBUTE_1 to all Lines so typo should be excluded!

Should ATTRIBUTE_1 and the value usable in {if}-conditions?



Obvious it does not work. Could this be a bug?
Thanks for help.
Martin
The topic has been locked.
  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago - 5 years 4 months ago #177427 by mad99
Replied by mad99 on topic SMALL BUG! HAVE FOUND THE SOLUTION
Hi,
Unfortunatelly the Expression-Manager in email-templates is render the placholder {TOKEN:ATTRIBUTE_1} in the right way and print-out the value «DU» in the email.

But in the {if}-condition expression, the same placeholder is not to use. The Output is nothing: not the «TRUE» part (first in the function), nor the «FALSE» part (second in the function).

With try&error I found the solution:
The Expression-Manager for text is working fine with the Placeholder {TOKEN:ATTRIBUTE_1} but for email, the part «TOKEN:» does NOT work!

[hr]

So for everybody who is searching a solution - here the right way to use {TOKEN:ATTRIBUTE_1} in email-templates:
Code:
{if(ATTRIBUTE_1 == 'SEARCH_VALUE', 'OUTPUT_IF_MATCH_TRUE', 'OUTPUT_IF_NO_MATCH_FALSE')}


[hr]

IMAGE of working solution in Expression-Manager:


IMAGE of working solution in Expression-Manager:



[hr]

So a documentation about all the {if}-conditions WITH WORKING SOLUTIONS for text AND Email would be lot more important: www.limesurvey.org/de/foren/design-issue...nd-real-life-example



Does anybody has some link or help to find them?


[hr]

Question to Forum-Admins:
What kind of bug/feature request I have to report in but-tracker? Any idea?
The bug reporting system is really hard to understand compared to other systems I know.
Last edit: 5 years 4 months ago by mad99.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177430 by holch
Replied by holch on topic SMALL BUG! HAVE FOUND THE SOLUTION
Yes, I think I remember that.

I don't think it is good in terms of compatibility and consistency to use ATTRIBUTE_1 in emails but TOKEN:ATTRIBUTE_1 in the rest of the survey.

Maybe a Feature request? I think this might be considered a "feature" by developers, but you never know.

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.
  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177432 by mad99
Replied by mad99 on topic SMALL BUG! HAVE FOUND THE SOLUTION
Thank you holch for help.

Have report a feature request for
- consistent use of Placeholder for {TOKEN:ATTRIBUTE_INT} > bugs.limesurvey.org/view.php?id=14287
- missing documentation for {if}-statement with real-world-examples and abstract-examples for both : email and survey-text. > bugs.limesurvey.org/view.php?id=14286

and a bug-report for
- cosistent use of {TOKEN:ATTRIBUTE_INT} in Expression-Manager in simple «value» output and «{if}-statement rendering» OR/AND missing error-mark in code behind button «validate expression» > bugs.limesurvey.org/view.php?id=14288

Hope will help in future users to save time or/and to code the system more consistently and error-free.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177442 by DenisChenu
Replied by DenisChenu on topic SMALL BUG! HAVE FOUND THE SOLUTION
We already replace TOKEN:ATTRIBUTE_X by ATTRIBUTE_X : github.com/LimeSurvey/LimeSurvey/blob/ma...min/tokens.php#L1340
Related issue : bugs.limesurvey.org/view.php?id=8683

Did you check if it work with ATTRIBUTE_X ?

Sending email to user is something totally unrelated to sending email to admin : TOKEN:ATTRIBUTE_1 is EMPTY for anonymous survey.

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.
  • mad99
  • mad99's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago - 5 years 4 months ago #177446 by mad99
Replied by mad99 on topic SMALL BUG! HAVE FOUND THE SOLUTION
Hi Denis, thank you for your information.

DenisChenu wrote: Did you check if it work with ATTRIBUTE_X ?

You mean in email-template: YES I used this at the end -> it works fine!

Or you mean in text for surveys? There I have used TOKEN:ATTRIBUTE_X -> it works. I don't try only {ATTRIBUTE_X} in text until now, but I will have a try.

But TOKEN:ATTRIBUTE_X in email-templates does not work in {if}-statement only in normal output. I guess.

DenisChenu wrote: Sending email to user is something totally unrelated to sending email to admin : TOKEN:ATTRIBUTE_1 is EMPTY for anonymous survey.


All tested e-mails are sending to user and NOT from anonmous surveys.
TOKEN:ATTRIBUTE_X is still not usable in {if}-statement, I guess.

If I misunderstood something and you still need to answer, just ask.
Last edit: 5 years 4 months ago by mad99.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177451 by DenisChenu
Replied by DenisChenu on topic SMALL BUG! HAVE FOUND THE SOLUTION
It's an issue with TOKEN:attribute inside equation, fixed in next release.

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.

Lime-years ahead

Online-surveys for every purse and purpose