I have only recently started using the salesforce marketing cloud (exact target) to send out emails, so if there’s something conceptually wrong with my question, forgive me :).
So let’s say I have email – with some text – where I would like to display a list of items in a form of:
Dear %%Name%%. Your items are: <table> <tr> <td> Item one id </td> <td> Item one text </td> </tr> <tr> <td> Item two id </td> <td> Item two text </td> </tr> </table>
This email is than sent out as a triggered send via api calls.
To populate this email with data I have created a Data Extension, where I defined a few fields, but I’m stuck on how to define the data for my list. So in this setup, what would be the best way of handling this situation?
I started looking into it and it seems like I can’t simply create an array type in my data extension. So I was wondering if maybe I should pass my items in text – either as xml/json serialize -, that I can later on somehow loop through in the email to build up the list?
But I didn’t really get anywhere.
Any help is greatly appreciated.
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Here are two ways to accomplish this with the API.
In your API call, include structured data in an attribute named
__HTMLexpands the max field length. This data will also be written to the Triggered Send Templated Data Extension you created for your trigger. The structured data payload can be XML or JSON. In the email, you can parse the XML payload with the BuildRowsetFromXML() AMPScript function and iterate through the result-set with a for-loop. Same for a JSON payload except with the parsing and iterating is done with SSJS or GTL. My recommendation would be to use AMPScript, because SSJS is slow and GTL is not documented very well.
- Before firing your trigger API call, add the rows to a secondary Data Extension. You can retrieve the data with an AMPScript lookup function and iterate through it in the email.
We generally work with XML payloads (option #1). Here are a couple of screenshots of a Triggered Send Data Extension: