Hi,
Links are breaking when trying to pull from custom object, the code is within a FOR LOOP - for testing purposes I have reduced the code. Anyone have any ideas why the links are breaking?
Working URL outside FOR/IF LOOP, pulling link from custom object(DynamicCustomObjectList) : ${DynamicCustomObjectList.get(1).URL_1}
Links not working when inside FOR loop:
#foreach( $co_record in $DynamicCustomObjectList)
<a href="https://${co_record.URL_1}">CLICK ME</a>
<br>
<a href="https://uk.website.com/${co_record.URL_1}">CLICK ME TO</a>
<br>
<a href="https://$co_record.URL_1">CLICK ME AGAIN</a>
#end
Output link break: https://%24%7Bco_record.url_1%7D/?mkt_tok=eyJpIjoiTkRoak5qTTNNREl6WVRaaSIsInQiOiJDVVwvZmlrSWpzUEgrdjlYV2VvMENHME5PZG0xcThHQVd3TEp4Y3l4WEJERXUrMlwvTUQ0TjdqNGE1WTNGa1RPUUgwbDh2VFlKeWc5dTdRMEM3YXRPZFd2VlVyUGlPSE4zc25WRCtiQThjWHg4b1FzcFB0b2VRUStsMjVwZVBlTGVvIn0%3D
The code is in an email script token, which then is added to a snippet and from that called into an email.
Thanks,
Haroon
Have you read Multiple Marketo-tracked links in Velocity ?
At the moment I'm not totally comfortable with Velocity scripting.
Is it possible to help with the example code provided?
#foreach( $co_record in $DynamicCustomObjectList )
#set( $currentURLNoProto = $co_record.URL_1 )
#foreach( $link in [1..3] )
#evaluate( "${esc.h}set( ${esc.d}URL_${foreach.parent.count}_${foreach.count} = ${esc.d}currentURLNoProto )" )
#end
#end
#if( $URL_1_1 )
<a href="https://${URL_1_1}">CLICK ME</a>
#end
#if( $URL_1_2 )
<a href="https://uk.website.com/${URL_1_2}">CLICK ME TOO</a>
#end
#if( $URL_1_3 )
<a href="https://${URL_1_3}">CLICK ME AGAIN</a>
#end
#if( $URL_2_1 )
<a href="https://${URL_2_1}">CLICK ME</a>
#end
#if( $URL_2_2 )
<a href="https://uk.website.com/${URL_2_2}">CLICK ME TOO</a>
#end
#if( $URL_2_3 )
<a href="https://${URL_2_3}">CLICK ME AGAIN</a>
#end
As noted in the blog post, because of Marketo's peculiarities when introspecting the data for links, you must preallocate individual variables (not properties) for each possible link.
Thanks Sanford! That helped loads.
There is a little issue, I have six links in the custom object to pick up but the code above only pulling the same link for each.
##set($co_record.URL_1 = $DynamicCustomObjectList.URL_1)
##set($co_record.URL_2 = $DynamicCustomObjectList.URL_2)
##set($co_record.URL_3 = $DynamicCustomObjectList.URL_3)
##set($co_record.URL_4 = $DynamicCustomObjectList.URL_4)
##set($co_record.URL_5 = $DynamicCustomObjectList.URL_5)
##set($co_record.URL_6 = $DynamicCustomObjectList.URL_6)
Is there a way to pull each link?
Thanks again,
Haroon
Please highlight your code using the Advanced Editor's syntax highlighter.
Then we'll continue.
Sorry, new to using the discussion.
I have 6 links within the CO which need pulling in, the example you gave seems to pull only URL_1 - is there a way to use the code you had provided and pull all 6 links?
Below is how I had set it up but links broke.
#set($co_record.URL_1 = $DynamicCustomObjectList.URL_1)
#set($co_record.URL_2 = $DynamicCustomObjectList.URL_2)
#set($co_record.URL_3 = $DynamicCustomObjectList.URL_3)
#set($co_record.URL_4 = $DynamicCustomObjectList.URL_4)
#set($co_record.URL_5 = $DynamicCustomObjectList.URL_5)
#set($co_record.URL_6 = $DynamicCustomObjectList.URL_6)
For example each link was added as -
<a href="https://$co_record.URL_1&CMP=e-email-tracking" target="_blank"><img src="$co_record.Image_1" width="100" style="border-collapse:collapse; padding:0px; margin:0px; border-spacing:0; display:block;"/></a>
<a href="https://$co_record.URL_2&CMP=e-email-tracking" target="_blank"><img src="$co_record.Image_2" width="100" style="border-collapse:collapse; padding:0px; margin:0px; border-spacing:0; display:block;"/></a>
<a href="https://$co_record.URL_3&CMP=e-email-tracking" target="_blank"><img src="$co_record.Image_3" width="100" style="border-collapse:collapse; padding:0px; margin:0px; border-spacing:0; display:block;"/></a>
Hope you can help.
Thanks,
Haroon
#set( $currentURLNoProto = $co_record.URL_1 )
#foreach( $link in [1..3] )
#evaluate( "${esc.h}set( ${esc.d}URL_${foreach.parent.count}_${foreach.count} = ${esc.d}currentURLNoProto )" )
#end#set($daysRemaining = $math.abs($daysRemaining))
##set($co_record.URL_1 = $DynamicCustomObjectList.URL_1)
##set($co_record.URL_2 = $DynamicCustomObjectList.URL_2)
##set($co_record.URL_3 = $DynamicCustomObjectList.URL_3)
##set($co_record.URL_4 = $DynamicCustomObjectList.URL_4)
##set($co_record.URL_5 = $DynamicCustomObjectList.URL_5)
##set($co_record.URL_6 = $DynamicCustomObjectList.URL_6)#if($convert.toInteger($daysRemaining) < 5 && $co_record.SendID == "Pattern Breakers Engineer")
<table id="bodyContent" class="innertable2" align="center" width="600" cellpadding="0" cellspacing="0" style="background-color:#ffffff;">
<tr>
<td valign="top"><table width="100%" style="font-size: 3px;">
<tbody>
<tr>
<td> </td>
</tr>
</tbody>
</table></td>
<td rowspan="6"><img src="http://planet.farnell.com/email/newtemplate/email_assets/spacer.gif" width="2" height="10" class="spacer"/></td>
<td rowspan="6" style="background-color:#e4e4e4;"><img src="http://planet.farnell.com/email/newtemplate/email_assets/spacer.gif" width="4" height="1"/></td>
<td rowspan="6"><img src="http://planet.farnell.com/email/newtemplate/email_assets/spacer.gif" width="2" height="10" class="spacer"/></td>
<td valign="top"><table width="100%" style="font-size: 3px;">
<tbody>
<tr>
<td> </td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td valign="top"><table width="289" border="0" cellspacing="5" cellpadding="5" class="innertable3">
<tr>
<td >
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr >
<td>
<table width="15%" border="0" cellspacing="0" cellpadding="0" align="right" class="w100">
<tr>
<td> <a href="https://${URL_1_1}" target="_blank"><img src="$co_record.Image_1" width="100" style="border-collapse:collapse; padding:0px; margin:0px; border-spacing:0; display:block;"/></a>
</td>
</tr>
</table><table width="15%" border="0" cellspacing="0" cellpadding="0" align="right" class="w100">
<tr>
<td> <a href="https://$co_record.URL_2" target="_blank"><img src="$co_record.Image_2" width="100" style="border-collapse:collapse; padding:0px; margin:0px; border-spacing:0; display:block;"/></a>
</td>
</tr>
</table>
Some sample code above utilizing code you provided, but link only pulling from $URL_1 CO field, I need to pull from $URL_2, $URL_3 etc..
You can pull from as many different properties as you want. Just follow the same pattern of creating a variable by evaluate-ing dynamic code.
In your example, you used the property .URL_1 three times, and you didn't refer to other properties.