Error with velocity token sending sample email: Rendered_Email_Velocity_Error_Area_?! Error invoking method 'get(java.lang.Integer)'
When trying to send a sample email that has a velocity token, I get the following error:
An error occurred when procesing the email Rendered_Email_Velocity_Error_Area_?! Error invoking method 'get(java.lang.Integer)' in java.util.ArrayList near |
The velocity token is attempting to create a Velocity variable from the value of a lead field:
#if( $lead.apptConfirmation.isEmpty() )
#set( $lead.apptConfirmation = '[]' )
#end
#set($myDetails = '#set( $myDetails = ' + $lead.apptConfirmation + ')' )
#evaluate( $myDetails )
${myDetails[0].LastName} <br/>
${myDetails[1].LastName} <br/>
If I changes line 05 to reference a static string instead of a lead field everything works:
#set($myDetails = '#set( $myDetails = ' + '[{"LastName": "Last1"},{"LastName": "Last2"}]' + ')' )
Any ideas why the top is not working?
It seems Marketo does not want me to reference a field within a #set directive.
I am essentially following the ideas laid out by Sanford Whiteman's blog on using JSON in Velocity but am getting this unexpected error so I assume others have gotten this to work.
Message was edited by: Digital Pi (changed 2nd 'email' to 'error' in first sentence
Peter Liske (peter@digitalpi.com)