SOLVED

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

Go to solution
Phillip_Wild
Level 10

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

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="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." 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="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a> and <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." 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="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, and <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=em..." 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="https://www.gadventures.com/trips/$MatchingToursDossiers[0]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[0]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[1]/?utm_source=Consumer_Promo&utm_medium=em..." style="text-decoration:underline; color:#47268d; font-size:16px; font-weight:bold;">$MatchingTours[1]</a>, <a href="https://www.gadventures.com/trips/$MatchingToursDossiers[2]/?utm_source=Consumer_Promo&utm_medium=em..." 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.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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).

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

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

Can you edit with syntax highlighting please?

Phillip_Wild
Level 10

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

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
Level 10 - Community Moderator

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

Yeah, use the Advanced Editor's Syntax highlighting:

pastedImage_2.png

SanfordWhiteman
Level 10 - Community Moderator

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

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).

Phillip_Wild
Level 10

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

Thanks so much Sanford! That has done the trick. I previously thought I had tested that -  but I'm guessing I used ${variable}[0] instead of ${variable[0]} . With the proper notation, this works just fine.

Your trick to show syntax is very useful too, thank you!