How to Format Integer with Leading Zeros

Hello,

I’m trying to format an integer value as a fixed-length string with leading zeros (e.g., converting 345 into "000345") within a Data Transform in Pega Infinity 24.2.2.

I’ve tried the following approaches:

  1. @String.format("%06d", .NextSeq)
    → This gives the error: Invalid expression or reference: No candidates found.

  2. @sprintf("%06d", .NextSeq)
    → Also not recognized — throws the same error.

  3. @pxNumber.FormatInt(.NextSeq, 6)
    → This seemed promising but isn’t recognized either in the DT expression context.

What’s the correct way (if any) to apply C-style format tokens like %06d or achieve the same result in a Data Transform, without using an Activity?

Thanks in advance!

@MaleeshaW

To format an integer with leading zeros in a Data Transform in Pega Infinity 24.2.2, you can’t use @String.format or @sprintf as they are not supported. Instead, use a combination of string functions like this: @substring(@concat("000000", @toString(.NextSeq)), @length(@toString(.NextSeq)), 6). This method adds six zeros in front of the number and then picks the last 6 characters to ensure the result is always 6 digits. For example, if the number is 345, the result becomes “000345”. This approach works in Data Transform without needing any Activity or Java code. It’s simple, reliable, and doesn’t require additional function rules. Make sure the total zeros in the concat match your expected length. This is a supported and safe method to format numbers with leading zeros.

@Sairohith Thanks! It worked.