Nice to be here.
I try to create an email on the basis of GTL. I open an AMPScript variable, which contains many key value pairs in a flat JSON format. I do this at the start of the mail like this:
{{.datasource ST type=variable maxRows = 1}}
{{.data}}
{ "target" : "@standardTranslations" }
{{/data}}
After all the content of the mail, which consists of multiple HTML paste content blocks, I end the datasource with:
{{/datasource}}
So far so good. I can access all the keys simply by typing {{ST.keyname}}, which is exactly what I wanted. But now a strange thing happens, when I generate a preview.
I get one working, nice mail, but appended to that a broken, duplicated version, which lacks the GTL personalizations.
The mailing itself is quite heavy on other AMPScript, but I took care, not to put GTL inside of an AMPScript If statement, as I read here on Stackexchange, that this is broken.
When I delete the GTL datasource I get none of the JSON keys resolved, obviously, but also the ugly duplicated mailing vanishes. So it clearly is related to the GTL datasource.
Has anybody experienced this behaviour before or even knows how to fix it?
EDIT:
The JSON looks like this:
[{"ViewEmailOnline":"Nëse ky email nuk shfaqet si duhet, ju lutemi klikoni","ViewEmailClickHere":"këtu."}]
For viewing the values in the mail, I use:
<td width="85%" valign="center" height="24" align="center">
<span style="color: #808890; font-size: 10px; font-family: Arial, sans-serif;">
{{ST.ViewEmailOnline}}
<a href="%%view_email_url%%" alias="VAWP" style="color: #808891; text-decoration: underline;">
<span style="color: #808891;">
<font color="#808891"> {{ST.ViewEmailClickHere}} </font>
</span>
</a>
</span>
</td>
Hope that helps to examine the problem a bit better. :-)
Oh, I also tried to use dataobject, but the problem is the same.
EDIT2:
I just did a minimal test and there the problem does not occur. The code looks like this:
<!--%%[
SET @Country = EnrollmentCountry
SET @Language = PreferredLanguage
SET @CountryLanguageKey = CONCAT(@Country,'-',@Language)
SET @standardTranslations = FIELD(ROW(LookupRows("StandardTranslationJSON_fixed","CountryLanguageKey",@CountryLanguageKey), 1),'Translations')
]%%
<div>
{{.datasource ST type=variable maxRows = 100}}
{{.data}}
{ "target" : "@standardTranslations" }
{{/data}}-->
<b>GTL says Hello:</b><br>
{{ST.Neutral_greeting_NoGender}} {{FirstName}}<br><br>
</div>
<b>And Goodbye:</b><br>
{{ST.Valediction_Enjoy}}<br><br>
<b>And We look at the imprint:</b><br>
{{ST.imprint-title}}<br><br>
{{/datasource}}
{{#=if ViewEmailOnline}} content {{/if}}
. and just select a field that will always have a value in your JSON. This way it may not solve the problem, but it will hide the symptom