1 Reply Latest reply on Feb 12, 2019 9:35 AM by Pip

    pad with leading zeros

    Pip Rookie

      Hi all

       

      I'm trying to work out how to pad a field with leading zeros but I cannot find a string function to do this.

       

      Specifically, I have a counter field for a new business object, with an initialisation rule on the record ID:

       

      $(Number(GetNextCounter("MyCounter")))

       

       

      I would like this to display with leading zeros on the form rather than just a single digit e.g. 00001234 rather than 1234

       

      Is there something I need to do to the counter or is this a formatting task?

       

      Many thanks

       

      Pip

        • 1. Re: pad with leading zeros
          Pip Rookie

          ....

           

          This is what I do:

           

          Create a new field, display ref ID, as a text field

           

          Add a calculation business rule as follows:

           

          $(Substring("00000000",  1,  8 - Len(ToString(RefID))) + ToString(RefID))

           

          Change the form to display the display ref id insread of the ref id.

           

          Would be nice to do this without the extra field though e.g. if we had a formatString() function