Velocity Script to Loop through Custom Objects
Hello, all. I am fairly new to Velocity scripting. Our Marketo Custom Objects store multiple fields of Engagement data that users submit through a form. I am trying to access the Product value on any number of Custom Objects/Engagements a lead may have.
When I drag the Product field into the Edit Script Token window it appears like this:
${marketoEngagement_cList.get(0).Product__c}
This will show the most recent value for Product that a lead submitted. I know that I can change the get(0) to get(1) to look at the second most recent, but how do I iterate through all of the potential engagements a lead may have to see the value of Product on each one?
Essentially, what I'm trying to do right now is to check if a particular value exists on any of the Product fields for any of the Custom Objects/Engagements. I will need to do more conditional checks later though, so I don't want to just do this for each one:
#set($lastProduct = ${marketoEngagement_cList.get(0).Product__c})
#if($lastProduct.contains("Product Name"))