Email template conditional formatting

More
2 months 1 day 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
2 months 1 day 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
1 month 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
1 month 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
1 month 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
1 month 3 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
1 month 3 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
1 month 3 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
1 month 3 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
1 month 3 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
1 month 3 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
1 month 3 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.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!