Email script not evaluating variable in live send, but does in preview | Community
Skip to main content
New Participant
October 27, 2017
Solved

Email script not evaluating variable in live send, but does in preview

  • October 27, 2017
  • 1 reply
  • 2330 views

Hi there

I'm trying to dynamically feed a variable into a URL but I'm having trouble. It works just fine in preview mode (which I know isn't the same as a live test) but when I send myself a sample email, it breaks - the URL variable outputs as $MatchingToursDossiers[0] instead of the actual value I need.

Here's the relevant code. Every other bit outputs as expected.

##set the matching tours arrays to be blank (this is our output)

#set ($MatchingTours = [])

#set ($MatchingToursDossiers = [])

##for each dossier that matches one in the Promo Map object, add it to the Matching Tours array.

#foreach ($wish in $DossierArray)

#if ($PromoMap[$wish])

#set ($dummy = $MatchingTours.add($TourDossierMap[$wish]))

#set ($dummy2 = $MatchingToursDossiers.add($wish))

#end

#end

##if no matching tours, print nothing. If one or more matching tours, print the relevant lines. And here's where it breaks down...$MatchingTours[0] outputs the text name just fine, but the $MatchingToursDossiers array doesn't resolve in the URL.

#if ($MatchingTours.size() == 0 )

#elseif ($MatchingTours.size() == 1 )

<tr>

<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> This might look familiar: <a href="gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a> from your Wish List is part of this sale! What are you waiting for?

</td>

</tr>

#elseif ($MatchingTours.size() == 2 )

<tr>

<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a> and <a href="gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a> from your Wish List are part of this sale! What are you waiting for?

</td>

</tr>

#elseif ($MatchingTours.size() == 3)

<tr>

<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, and <a href="gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[2]</a>

from your Wish List are part of this sale! What are you waiting for?

</td>

</tr>

#else

<tr>

<td align="center" valign="top" bgcolor="#ffffff" class="bodyText" style="padding-top:0;padding-bottom:30px;padding-right:15px;padding-left:15px;border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#000000;font-size: 16px; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; text-align: left; line-height:24px; mso-line-height-rule:exactly;vertical-align:top;text-decoration:none; font-weight:400;"> These might look familiar: <a href="gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, <a href="gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=email&utm_campaign=Stop_Book_Go_Start" style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[2]</a>, and more

from your Wish List are part of this sale! What are you waiting for?

</td>

</tr>

#end

#end

Any ideas as to why this is breaking in this fashion? I've tried using $MatchingToursDossiers.get(0) and $MatchingToursDossiers(0) with no result.

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

First, try this with formal notation instead as it helps disambiguate tokens within a string:

/trips/${MatchingToursDossiers[0]}/?utm_...

However I wonder if this is indeed the issue, or something more sinister that can happen with multiple links (see this post).

1 reply

SanfordWhiteman
New Participant
October 27, 2017

Can you edit with syntax highlighting please?

New Participant
October 27, 2017

Hi Sanford

Sorry, I'm not exactly sure what you mean. Do you mean highlighting the code vs the comments? If there's a better way to display this let me know - it doesn't make it easy on the eyes!

SanfordWhiteman
New Participant
October 27, 2017

Yeah, use the Advanced Editor's Syntax highlighting: