I'm running into this same issue. If I build the #foreach loop such as:
#foreach ( $opportunity in $OpportunityList)
$opportunity.CloseDate
$opportunity.oOpportunityFSID
#end
and if there are 3 opportunities with the first opportunity having a close date of 2015-01-5 and an FSID of 005xxx, the result is:
2014-01-05 005xxx 2014-01-05 005xxx 2014-01-05 005xxx
The docs (Email Scripting » Marketo Developers ) show this being nice and easy:
Now, for the opportunity example, you don't really need the math element, so:
This offers the same repetitive result, returning only the first result multiple times. Is the #if statement required for this to be successful? What am I missing?
I don't have a link to the docs, but if you want to describe your problem, I might be able to help. I've written a few email scripts around extracting opportunity info.
got a script to pull the most recent opportunity date ? We are trying to pull just the most recent opportunity for a particular script, but are stuck so to speak (the script takes the opportunity at the bottom of the opportunity list in marketo, which would be the oldest.
This is the script thus far, we are just missing a bit of code to specify most recent
#foreach($opportunity in $OpportunityList)
#if($opportunity.o_opportunity_type == "Home Loan" && $opportunity.o_funded)
${OpportunityList.get(0).Name}
#break
#end#end