1

According to the documentation you should be able to set the data type of a variable using a kind parameter:

  • N - number
  • C - currency
  • D - date

For example:

{{example [kind=N]}}

or

{{example [k=N]}}

However, we can't get this to work.

In our JSON object we have an order summary object:

   "Order Summary":{  
      "Order Sub Total":120.00,
      "Total Loyalty Discount":12.00,
      "Total Coupon Amount":5.00,
      "Total Shipping Amount":0.00,
      "Total Order Amount":130.00,
      "Total Tax Amount":1.30
   }

If I include the tag {{[Order Sub Total]}} it's rendered as 120.

I have tried using:

{{[Order Sub Total] [k=C]}}

and

{{[Order Sub Total] [kind=C]}}

But the decimal places are not displayed.

I've also tried [k=N] but that doesn't work either.

We've managed to work around this issue by using GTL in combination with AMPscript:

{{.datasource totals type=nested}}
  {{.data}}
    {"target":"order.[Order Summary]"}
{{/data}}
%%[
SET @sub = FormatNumber(TreatAsContent('{{[Order Sub Total]}}'), "C2", "en-AU")
SET @lld = FormatNumber(TreatAsContent('{{[Total Loyalty Discount]}}'), "C2", "en-AU")
SET @coup = FormatNumber(TreatAsContent('{{[Total Coupon Amount]}}'), "C2", "en-AU")
SET @sr = FormatNumber(TreatAsContent('{{[Total Shipping Amount]}}'), "C2", "en-AU")
SET @tot = FormatNumber(TreatAsContent('{{[Total Order Amount]}}'), "C2", "en-AU")
SET @ta = FormatNumber(TreatAsContent('{{[Total Tax Amount]}}'), "C2", "en-AU")
]%%
{{/datasource}}

We then display the AMPscript variable in the email. This works, but I'm keen to find out if the variable data type feature is broken or whether my syntax is incorrect.

2

I've received a response from Salesforce (actually the GTL engineering team) who acknowledge that GTL data types are currently not functioning. This should be resolved in a future release. In the meantime, you need to use AMPscript (as per the workaround that I provided in my original question).

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.