Email template conditional formatting

More
3 months 3 weeks ago #172512 by terryaulenbach
terryaulenbach created the topic: Email template conditional formatting
I'm trying to set up my email notification templates so that certain multiple choice responses will be included if they have been selected. I have a number of possible answers, but don't want blank lines to show if certain answers weren't selected. Here's what I've started with:

<tr>
<td style="vertical-align: top;"><strong>Topics to review:</strong></td>
<td
{INSERTANS:415993X2706X34550A1}<br />
{INSERTANS:415993X2706X34550A2}<br />
{INSERTANS:415993X2706X34550A3}<br />
{INSERTANS:415993X2706X34550A4}<br />
{INSERTANS:415993X2706X34550A5}<br />
{INSERTANS:415993X2706X34550A6}<br />
{INSERTANS:415993X2706X34550A7}<br />
{INSERTANS:415993X2706X34550A8}<br />
{INSERTANS:415993X2706X34550A9}</td>
</tr>

Is there some way to use an if statement so I don't have the extra <br /> tags?

Terry

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

More
3 months 3 weeks ago #172526 by tpartner
tpartner replied the topic: Email template conditional formatting
I don't think you can do it with SGQA values but you could try something like this with Expression Manager variables:

{if(!is_empty(Q1_SQ001), 'Q1_SQ001: '+Q1_SQ001+'<br />', '')}		
{if(!is_empty(Q1_SQ002), 'Q1_SQ002: '+Q1_SQ002+'<br />', '')}		
{if(!is_empty(Q1_SQ003), 'Q1_SQ003: '+Q1_SQ003+'<br />', '')}		
{if(!is_empty(Q1_SQ004), 'Q1_SQ004: '+Q1_SQ004+'<br />', '')}

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

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

More
3 months 3 weeks ago #172850 by terryaulenbach
terryaulenbach replied the topic: Email template conditional formatting
Hey, Tony. This works... kind of. Any time any email templates are touched after the initial save, it stops working again and the code gets rearranged like so:

{if(!is_empty(WCHelp_A1), WCHelp_A1.question+'<br />
', '')} {if(!is_empty(WCHelp_A2), WCHelp_A2.question+'<br />
', '')} {if(!is_empty(WCHelp_A3), WCHelp_A3.question+'<br />
', '')} {if(!is_empty(WCHelp_A4), WCHelp_A4.question+'<br />
', '')} {if(!is_empty(WCHelp_A5), WCHelp_A5.question+'<br />
', '')} {if(!is_empty(WCHelp_A6), WCHelp_A6.question+'<br />
', '')} {if(!is_empty(WCHelp_A7), WCHelp_A7.question+'<br />
', '')} {if(!is_empty(WCHelp_A8), WCHelp_A8.question+'<br />
', '')} {if(!is_empty(WCHelp_A9), WCHelp_A9.question+'<br />
', '')} {if(!is_empty(WCHelp_other), 'Other: '+WCHelp_other.value+'<br />
', '')} {if(!is_empty(LibraryHelp_A1), LibraryHelp_A1.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A2), LibraryHelp_A2.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A3), LibraryHelp_A3.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A4), LibraryHelp_A4.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A5), LibraryHelp_A5.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A6), LibraryHelp_A6.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A7), LibraryHelp_A7.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A8), LibraryHelp_A8.question+'<br />
', '')} {if(!is_empty(LibraryHelp_A9), LibraryHelp_A9.question+'<br />
', '')} {if(!is_empty(LibraryHelp_other), 'Other: '+LibraryHelp_other.value+'<br />
', '')}

This bit of the email ends up looking like this:

if( ! is_empty(WCHelp_A1), WCHelp_A1.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A2), WCHelp_A2.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A3), WCHelp_A3.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A4), WCHelp_A4.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A5), WCHelp_A5.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A6), WCHelp_A6.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A7), WCHelp_A7.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A8), WCHelp_A8.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_A9), WCHelp_A9.question + ' < br / > ', ' ' ) if( ! is_empty(WCHelp_other), 'Other: ' + WCHelp_other.value + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A1), LibraryHelp_A1.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A2), LibraryHelp_A2.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A3), LibraryHelp_A3.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A4), LibraryHelp_A4.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A5), LibraryHelp_A5.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A6), LibraryHelp_A6.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A7), LibraryHelp_A7.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A8), LibraryHelp_A8.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_A9), LibraryHelp_A9.question + ' < br / > ', ' ' ) if( ! is_empty(LibraryHelp_other), 'Other: ' + LibraryHelp_other.value + ' < br / > ', ' ' )

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

More
3 months 3 weeks ago #172854 by tpartner
tpartner replied the topic: Email template conditional formatting
Don't use the HTML editor.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, LouisGac

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

More
3 months 3 weeks ago #172862 by terryaulenbach
terryaulenbach replied the topic: Email template conditional formatting
OK, thanks. But my curiosity needs to be satisfied... what is it about the editor that breaks the code? Is it something that can be fixed in future updates?

Terry

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

More
3 months 2 weeks ago #172872 by LouisGac
LouisGac replied the topic: Email template conditional formatting
In LS4 the text editor will be changed.

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

More
3 months 2 weeks ago #172879 by tpartner
tpartner replied the topic: Email template conditional formatting
Changed to what?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

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

More
3 months 2 weeks ago #172884 by jelo
jelo replied the topic: Email template conditional formatting

LouisGac wrote: In LS4 the text editor will be changed.

A wiki roadmap page for LS 4 might help. ETA End of 2019. New HTML Editor. What else is already sealed?

Are you a student conducting a survey? If yes, tell me why you use LimeSurvey?
www.limesurvey.org/forum/development/116...y-you-use-limesurvey

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

More
3 months 2 weeks ago #172971 by terryaulenbach
terryaulenbach replied the topic: Email template conditional formatting
OK, so I did my editing without switching to HTML. Same problem. If I make changes to one template, save, make changes to the other template and save, the first template gets messed up. I suppose I can change both and then change, but I will always have to remember that any time I update ANYTHING in ANY of the email templates, I'll have to go back and re-enter the code for the 2 notification templates and save both at the same time to avoid sending messed up emails. Is there not a better solution?

Terry

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

More
3 months 2 weeks ago #172972 by tpartner
tpartner replied the topic: Email template conditional formatting
Disable the HTML editor before opening the template editing screen. They are all loaded together, just in hidden tabs.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

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

More
3 months 2 weeks ago #172978 by terryaulenbach
terryaulenbach replied the topic: Email template conditional formatting
Sorry, but I can't see where to disable it.

Terry

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

More
3 months 2 weeks ago #172979 by holch
holch replied the topic: Email template conditional formatting
manual.limesurvey.org/Global_settings#General

Default editor mode:

Default HTML editor mode: Sets the default mode for integrated HTML editor. The valid settings are:
inline (default): Inline replacement of fields by an HTML editor. Slow, but convenient and user-friendly
popup : Adds an icon that opens a popup window with the HTML editor. Faster, but the HTML code is displayed on the form
HTML source : No HTML editor used, just the plain html source


You will want to set the last option "HTML source". This sets it or the whole installation on all users.

You can also set this on your user preferences, but others might still run into the same problem. If you are the only one doing this kind of stuff, then this is probably the way to go:

manual.limesurvey.org/First_login_-_your...ces#HTML_editor_mode

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: tpartner

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

More
2 weeks 18 hours ago #177548 by Panoramic
Panoramic replied the topic: Email template conditional formatting
Hello, i've been reading this post and i have one question related to it:

In my email templates, can I add the 'text answer' of some question? I explain it:
I'm doing a survey in which i have uploaded to LimeSurvey a matrix with participants (each one with a token) and their responses from a csv file, wich are the responses from last year's survey (we do this once per year). I would like to send them an invitation email with:

{TOKEN:FIRSTNAME} {TOKEN:LASTNAME}

URL + personal password to acces the survey {TOKEN}

-> The response from one of the survey questions. This question stands for their organitzation, it is a free text question that asks them wich institution do they belong to, because there are people doing the survey for several organitzations (one person that belongs to different institutions)

Can I introduce this in the email template without the Expression Manager? So I can send the mail to all of these participants with their name and surname, their token and the name of their organization.

Thanks,
Eloi.

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

More
2 weeks 16 hours ago #177564 by holch
holch replied the topic: Email template conditional formatting
Of course yu can. You probably saved this answer under a custom attribute, let's call it ATTRIBUTE_1.

In this case you can call it either via {TOKEN:ATTRIBUTE_1} or {ATTRIBUTE_1}, I am currently not sure which one works in emails. I think in the emails you must not use the "TOKEN:" part (because the information can only come from the token table anyway with emails).

So it is probably {FIRSTNAME} {LASTNAME} and {ATTRIBUTE_1} (or in whatever custom attribute you saved it.

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

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

More
2 weeks 13 hours ago #177582 by Panoramic
Panoramic replied the topic: Email template conditional formatting
Thank you Holch!

I didn't save this answer as an attribute, it was a question inside the survey; so I've created the attribute 'Organization', i have downloaded the participants file and i filled the 'attribute' column in the csv file. Then i imported it again to Lime. In the template it works perfectly.

Thanks again,
Eloi.

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!