Stuck on Velocity issue. Displaying list of values = overwriting | Community
Skip to main content
Raj_Singh4
New Participant
January 16, 2020
Solved

Stuck on Velocity issue. Displaying list of values = overwriting

  • January 16, 2020
  • 1 reply
  • 1685 views

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
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman
#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

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
January 16, 2020
#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