SOLVED

Stuck on Velocity issue. Displaying list of values = overwriting

Go to solution
Level 1

Stuck on Velocity issue. Displaying list of values = overwriting

The JSON data will come in like this. 

[{"vehicleYear": 2018, "vehicleMake": "Mercedes-Benz", "vehicleModel": "GLC", "requiredDocs": [{"Docs":"Proof of Income,OTHER DOC1,OTHER DOC2"}]}]

I need to output the string of Docs into a bulleted list in the email body. The code I have so far does successfully export the Docs list if I echo out $subvalue. The issue is when I put the <li> HTML script in the token used in the body of the email. It displays the very last value in the string (OTHER DOC2) since Proof of Income is overwritten by OTHER DOC1 and then by OTHER DOC2. How do I display each value in its own bullet and code it to be scaleable if the number of Docs is more than 3?

##set defaults
#set( $utm_source = "mkto-email" )
#set( $utm_medium = "customer-engagement" )
#set( $utm_campaign = "post-purchase-missing-docs" )
#set( $vehicleYear = "" )
#set( $vehicleMake = "" )
#set( $vehicleModel = "" )
#set( $residenceBullet = "" )
#set( $missingDocs = "" )
##check JSON and set vars
#if( $lead.missingdocsJSON.isEmpty() )
#set( $lead.missingdocsJSON = '[]' )
#elseif( $lead.missingdocsJSON )
#set( $missingdocData = '#set( $missingdocData = ' + ${lead.missingdocsJSON} + ' )' )
#evaluate($missingdocData)
#end
#foreach( $missingdoc in $missingdocData )
#set( $vehicleYear = $missingdocData[0].vehicleYear )
#set( $vehicleMake = $missingdocData[0].vehicleMake )
#set( $vehicleModel = $missingdocData[0].vehicleModel )
#set( $requiredDocs = $missingdocData[0].requiredDocs )
#end
#set( $sepDocs = $requiredDocs[0].Docs.split(",") )
#foreach( $subvalue in $sepDocs)
#set ( $bullets = $subvalue )
#end
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Stuck on Velocity issue. Displaying list of values = overwriting

#foreach( $missingDoc in $missingdocData )
#foreach( $requiredDocSets in $missingDoc.requiredDocs )
#foreach( $requiredDocSet in $requiredDocSets.values() )
<ul>
#foreach( $requiredDoc in $requiredDocSet.split(",") )
<li>${requiredDoc}</li>
#end
</ul>
#end
#end
#end

View solution in original post

1 REPLY 1

Re: Stuck on Velocity issue. Displaying list of values = overwriting

#foreach( $missingDoc in $missingdocData )
#foreach( $requiredDocSets in $missingDoc.requiredDocs )
#foreach( $requiredDocSet in $requiredDocSets.values() )
<ul>
#foreach( $requiredDoc in $requiredDocSet.split(",") )
<li>${requiredDoc}</li>
#end
</ul>
#end
#end
#end

View solution in original post