I'm having trouble accessing anything other than the first element in a Marketo Custom Object through email scripting.
I've tested using a few leads, and here's the behaviour I'm seeing. All leads had at least three entries in the relevant Marketo Custom Object:
* ${MarketoCustomObject_cList.get(0).fieldName} resolves correctly with the first element in the array when using "Send Sample Email".
* ${MarketoCustomObject_cList.get(1).fieldName} gives me no errors, but doesn't send the sample email when I use "Send Sample Email".
* ${MarketoCustomObject_cList.get(2).fieldName} gives me no errors, but doesn't send the sample email when I use "Send Sample Email".
Why would this be occurring? According to this page: http://developers.marketo.com/email-scripting/
"For each custom object, the 10 most recently updated records per person/contact are available at runtime and are ordered from last updated(at 0) to oldest updated(at 9)."
Any ideas? I really hope this can be resolved.
Thanks in advance.
Always test Velocity scripts with real emails, not samples!
The quickest way to debug ArrayList output is to output the full list. It will be automatically stringified:
${MarketoCustomObject__cList}
Bear in mind that, in production, you definitely have to check to see if the index exists --
#if( $MarketoCustomObject__cList.size() > 2 )
## .. stuff that expects index 2 to exist...
#end
-- as accessing a nonexistent index is a fatal error in Velocity.
Thanks so much Sanford. Outputting the entire array is a great way to test! I should have thought of that
After some more testing, it seems that this error is purely related to the fact I was testing using "Send Sample Email" instead of Single Flow Actions. Lesson learnt! Phew. Very glad to see something this fundamental isn't broken in Marketo...