sendgrid/email-templates

Iterating through a list object - Handlebars

Fuji183 opened this issue · 0 comments

Actual Behaviour

After communicating with the SendGrid engineers we have settled on a format / structure for our JSON payload and so far we have been able to reference values / properties using Handlebars syntax for our Dynamic templates. However, we now have to include properties that can be a list of values and the Handlebar syntax being used is unable to evaluate at run time

Expected Behaviour

The Dynamic template should be able to display the values within the list array

Steps to reproduce it

JSON file is structured as so:

{
"personalizations":[
{
"subject":"Waive Fee",
"dynamic_template_data":{
"template_data":[
{
"insurance":[
{
"PolicyType":"Comprehensive",
"InsuranceProvider":"Blue Elephant",
"InsuranceFinanced":false,
"InsurancePremium":0.0,
"PolicyId":""
}
],
"pyNote":"",
"pyApproveStatus":"Decline",
"CaseID":"S-7160",
"waiveFeeList":[
{
"Comments":"This is a test",
"DueDateValue":"29/06/2017",
"InvoiceNumber":"0014593711",
"InvoiceAmount":3.25,
"Reason":"Goodwill"
}
],
"userDetails":{
"pyUserName":"mrinalini",
"pyFirstName":"James",
"pyUserIdentifier":"mdubey",
"pyPosition":"",
"pyEmailAddress":"",
"pyTelephone":""
},
"customer":{
"Brand":"GENERIC",
"PartyRole":"",
"CifNbr":"CUST-77472",
"FirstName":"Paul",
"FullName":"Paul Tabbiner",
"ShortName":"Paul Tabbiner",
"LastName":"Tabbiner",
"OnyxID":"75422643",
"CustomerType":"Individual"
}
}
]
},
"to":[
{
"email":"rcsquest@gmail.com",
"name":"Paul Tabbiner"
}
],
"custom_args":{
"sourceSystem":"PEGA CRM",
"correlationId":"3b3e1db9-65f7-42de-bc80-186a4566e40c"
}
}
],
"reply_to":{
"email":"rcsquest@gmail.com",
"name":"Test Account"
},
"from":{
"email":"rcsquest@gmail.com",
"name":"Test Account"
},
"template_id":"d-eecec6cea3f049178816d411b9bde1b3"

}

An example of the Handlebars syntax being used to dynamically populate a Dynamic template with the 'Comments' value (that doesn't work):

								<ol>
							{{#each template_data.waiveFeeList}}
							<p><li>{{Comments}}</li>
							
							{{/each}}
							</ol>   

Please let us know if you can work on it or the issue should be assigned to someone else.

I can work on this issue
ListTest_sendgrid.txt
WaiveFee_template.txt