Validation error approving with Email Approve when using the Velocity Code
I am facing the issue when approving email below is the error which Marketo throws Validation Error approving
An error occurred when procesing the email Rendered_Email_Velocity_Error_Area_?!
Error invoking method 'get(java.lang.Integer)' in java.util.ArrayList near
below is my VTL code which I tried to implement in email and when I preview the sample email it work perfect but when approving the email it throws above error
#set( $default_Name_Recipe_1 = "#" )
#set( $arrCounter = 0 )
#set ($index = 0)
#set( $prodRecoArr = [""] )
#set( $recoURL = [""] )
#set($one = 1)
#if( $CO_cList.isEmpty() )
#set( $defaultNameRec1 = $default_Name_Recipe_1 )
#else
#foreach( $CO_c in $sorter.sort($CO_cList, "recommendationDateStart:desc") )
#if( !$display.alt($CO_c["recommendationURL"],"").isEmpty()&& ($CO_c["recommendationName"]=="Recipe"))
#set($prodRecoArr[${arrCounter}] = $CO_c["recommendationURL"])
#set( $arrCounter = $arrCounter + 1)
#break
#end
#end
#end
#if ($prodRecoArr.size() >= 1 && ($CO_c["recommendationName"]=="Recipe") )
#set($index = $arrCounter - 1)
#set( $recoURL = ${prodRecoArr[${index}].split("//")})
<a href="https://${recoURL[$one]}">VTL test</a>
#else
${defaultNameRec1}
#end
In the above VTL, I am displaying data from CO table for product URL and using in email. Can anyone help on this issue?