Nov 23, 2018 3:10 AM
Hi,
How to send list of objects to email template using custom property in single send api. Please go through below example template.
{{custom.RecommendationSteps }}
Topic Name: {{item.TopicName}}
{% endfor %}{"emailId":"XXXXXX","message":{"to":"XXXXXXXXXX@XXXX.xxx"},"contactProperties":,"customProperties":[
{"name":"RecommendationSteps", "value":[{"name":"TopicName", "value":"TopicNamexyz"},{"name":"TopicName", "value":"xyz"}]
}]
}
Solved! Go to Solution.
Nov 27, 2018 10:57 AM
Welcome, @Bharat_Challapally!
At this time, custom properties passed via the single send API cannot be used in HubL for
loops.
The reasoning is the same as it is for if
statements — all HubL logic executes before custom properties and tokens are populated.
Here are some related topics:
The team understands this is a pain point and hopes to support greater HubL flexibility in email templates in the future.
In the meantime, the best way to surface multiple property values in the same template is to pre-render the values in an HTML table and pass the HTML into the custom token.
Something like:
{{custom.Table}}
{
"emailId":"XXXXXX",
"message": {"to":"XXXXXXXXXX@XXXX.xxx"},
"contactProperties":[],
"customProperties":[
{"name":"Table", "value": "<div><ul><li>TopicNameABC<\/li><li>TopicNameXYZ<\/li><\/ul><\/div>"
}
]
}
While this method works, I recognize it isn't an ideal solution and places the burden on you as the developer.
Isaac TakushiAssociate Certification Manager |
Apr 7, 2021 10:09 AM
I am also wondering if any work has been done to resolve this problem?
Same questions as above:
This puts the burden on the developer to write custom html and send it via custom properties to the email template. This is especially burdensome to work across marketing/development departments any time a small change needs to made to an email template. I greatly appreciate any response in regards to this.
Nov 27, 2018 10:57 AM
Welcome, @Bharat_Challapally!
At this time, custom properties passed via the single send API cannot be used in HubL for
loops.
The reasoning is the same as it is for if
statements — all HubL logic executes before custom properties and tokens are populated.
Here are some related topics:
The team understands this is a pain point and hopes to support greater HubL flexibility in email templates in the future.
In the meantime, the best way to surface multiple property values in the same template is to pre-render the values in an HTML table and pass the HTML into the custom token.
Something like:
{{custom.Table}}
{
"emailId":"XXXXXX",
"message": {"to":"XXXXXXXXXX@XXXX.xxx"},
"contactProperties":[],
"customProperties":[
{"name":"Table", "value": "<div><ul><li>TopicNameABC<\/li><li>TopicNameXYZ<\/li><\/ul><\/div>"
}
]
}
While this method works, I recognize it isn't an ideal solution and places the burden on you as the developer.
Isaac TakushiAssociate Certification Manager |
Mar 18, 2020 10:21 AM
In regards to this:
The team understands this is a pain point and hopes to support
greater HubL flexibility in email templates in the future.
Some questions: