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}} 

Result in Email


Expected :


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
    can you make the field type in Salesforce a String instead of an Integer? – Calvin OKeefe May 7 '19 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. – Mahmoud Gueye May 7 '19 at 15:59

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

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

here is the doc for using Ampscript within GTL


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

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.