2

I need to display numeric value in transnational email. I'm parsing json with GTL. Some times the payload can have a value like 012345, but in the email the display is 12345. I tried to format with formatNumber() in ampscript but the "0" is still truncated.

Json payload saved in the DE:

[{"FulfillmentDetail":{"TrackingNumber": "012345"} }]

Parsing wwith GTL :

{{.datasource FulfillmentDetail type=nested maxRows = 1}} 
           {{.data}} { "target" : "OrderLine.FulfillmentDetail" } {{/data}} 
            {{TrackingNumber}}
{{/datasource}} 

Result in Email

12345

Expected :

012345

The alternative solution is to add the value between single quotes. But this would implies tricky dev in the applications that launch the payload. So i'm searching to resolve this during the parse, in GTL/ampScript

2
  • 2
    can you make the field type in Salesforce a String instead of an Integer? Commented May 7, 2019 at 15:41
  • It's already on String. The value "012345" is well saved in SFMC DE, but the parse with GTL convert it directly to numeric. Commented May 7, 2019 at 15:59

3 Answers 3

3

If you use the formatnumber function you can keep the leading zero:

{{=formatnumber(TrackingNumber, "d6")}}

here is the doc for using Ampscript within GTL

0
1

Another solution is using format function that can retrieve both numeric with leading zero and string char

{{=format(TrackingNumber, '0#####')}}

Thanks @EazyE AMPScript/GTL function to check if variable is string or a numeric

1

I've found that if you concatenate the value with an empty string, it will return a string that will include the leading zeros.

For example: TreatAsContent("{{=concat(var_name, '')}}")

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .