0

As per the GTL documentation you open up the datasource to start using it, then close it off at the end of the content:

{{.datasource datasourceName [type=<datasourcetype>] [maxRows=<int>] [global=true or false]}}
     {{.data}} ... user data ... {{/data}}
     CONTENT GOES HERE               
{{/datasource}}

This works fine, but we can't get this to work reliably when we need to have two or more data sources open at the same time.

We need to do this as we're displaying values from two different data sources in the same email content. For example, we open two datasource blocks at the beginning of the email, then close them off at the end:

{{/datasource}}
{{/datasource}}
</body>
</html>

When we do this we get very strange behavior. Check this out. The fields in this table are pulled from one datasource:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tbody>
      <tr>
        <td align="left" valign="top" bgcolor="#ffffff" style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #404040; line-height: 21px; mso-line-height-rule: exactly; text-align: left;padding-bottom:30px;">
        <span class="appleLinks">Amount transferred to us: <strong>{{rollinAmount}}</strong><br />
        Untaxed amount: <strong>{{rollinUntaxedAmount}}</strong><br />
        Contributions tax paid: <strong>{{rollinContTax}}</strong><br />
        Amount invested in your account: <strong>{{rollinNetAmount}}</strong><br /></span></td>
      </tr>                           
    </tbody>
</table>

But when the email is previewed this is what we see:

preview

Note that it's actually put in the {{rollinAmount}} value of $46.93 and {{rollinContTax}} of $0.00 on the next line! Also note that the HTML <br />Contributions tax paid: string has completely dissapeared!

The only workaround that we've come up with so far is to set the variables using the TreatAsContent() AMPscript function at the start of the page:

{{.datasource details type=variable source=@template}}
  {{.data}}
    {"target":"@template"}
  {{/data}}
%%[
SET @mno = TreatAsContent('{{memberNumber}}')
SET @eno = TreatAsContent('{{employerNo}}')
SET @r1 = TreatAsContent('{{rollinAmount}}')
SET @r2 = TreatAsContent('{{rollinUntaxedAmount}}')
SET @r3 = TreatAsContent('{{rollinContTax}}')
SET @r4 = TreatAsContent('{{rollinNetAmount}}')
SET @url = TreatAsContent('{{webAddress}}')
{{/datasource}}

This works, but it's not very scalable if we need to declare each variable before we use it.

Does anyone have an alternate solution to this?

1

I received a response from the Marketing Cloud engineering team. It turns out that using AMPScript IF statements around Guide syntax currently results in unexpected behavior. In our HTML we were using Guide tags within AMPScript IF statements. This is clearly a defect and I assume will be rectified in a future release.

In the meantime, as a solution, you can use Guide's IF built-in block helper as per the example below:

%%[SET @template = '{"Amount":"100"}']%%

{{.datasource details type=variable source=@template}}
   {{.data}}
      {"target":"@template"}
   {{/data}}

Outside: {{Amount}}<br />

{{#if Amount <= 99 }}
Inside: {{Amount}}<br />
{{/if}}

{{/datasource}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.