Skip to main content
Level 2
Nov 6, 2017 12:31 AM UTC
Question

Email script to hide fields when value is blank

I have added email script to pull through custom fields into a table using Mytokens - see below - this lead only has 3 funds - the maximum # of funds is 9.

The details of your other super funds*

Fund name

Member Number

Code

Fund 1

1

11

Fund 2

2

22

Fund 3

3

33

${lead.otherfundname4}

${lead.otherfundnumber4}

${lead.uSI4}

${lead.otherfundname5}

${lead.otherfundnumber5}

${lead.uSI5}

${lead.otherfundname6}

${lead.otherfundnumber6}

${lead.uSI6}

${lead.otherfundname7}

${lead.otherfundnumber7}

${lead.uSI7}

${lead.otherfundname8}

${lead.otherfundnumber8}

${lead.uSI8}

${lead.otherfundname9}

${lead.otherfundnumber9}

${lead.uSI9}

I need to hide the tokens when the field value is blank so that the table resizes. Can anyone help with this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

SanfordWhiteman
User Group Leader
User Group Leader
Nov 6, 2017 1:09 AM UTC

#foreach( $fund in [1..9] )

#if( !$lead["otherfundname${fund}"].isEmpty() )

<tr><td>${lead["otherfundname${fund}"]}</td><td>${lead["otherfundnumber${fund}"]}</td><td>${lead["uSI${fund}"]}</td>

#end

#end

Translate
sdutoit-2Author
Level 2
Nov 6, 2017 3:57 AM UTC

Thanks @Sanford Whiteman​ I tried copying and pasting your code above underneath my other email script and it didn't work.

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Nov 6, 2017 4:03 AM UTC

(a) "It didn't work" isn't enough info to go on.

(b) Why would you paste my code underneath your other script? I can't undo the unwanted output from your script.  I'm showing you how to create the conditional output: looping over the possible variables and only outputting the non-empty ones.

Translate
Kirstie_Olah
Level 2
Oct 16, 2020 2:51 AM UTC

Hi there,

Did you work this out as I have the same query and issue I need to solve for a campaign. Can you show me what you did to get it to work.

 

Many thanks.

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Oct 16, 2020 5:31 AM UTC

See my answer on your other post.

Translate